提交 be967e8c 编写于 作者: X Xin Zhang 提交者: Ashwin Agrawal

Unittest HandleFtsWalRepProbe().

Signed-off-by: NTaylor Vesely <tvesely@pivotal.io>
上级 cc547d62
subdir=src/backend/fts
top_builddir=../../../..
include $(top_builddir)/src/Makefile.global
ifeq ($(enable_segwalrep), yes)
TARGETS=ftsprobehandler
include $(top_builddir)/src/backend/mock.mk
ftsprobehandler.t: \
$(MOCK_DIR)/backend/utils/error/assert_mock.o \
$(MOCK_DIR)/backend/utils/error/elog_mock.o \
$(MOCK_DIR)/backend/storage/lmgr/lwlock_mock.o \
$(MOCK_DIR)/backend/replication/gp_replication_mock.o \
$(MOCK_DIR)/backend/lib/stringinfo_mock.o \
$(MOCK_DIR)/backend/libpq/pqformat_mock.o \
$(MOCK_DIR)/backend/libpq/pqcomm_mock.o
endif
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include "cmockery.h"
#include "postgres.h"
#define Assert(condition) if (!condition) AssertFailed()
bool is_assert_failed = false;
void AssertFailed()
{
is_assert_failed = true;
}
/* Actual function body */
#include "../ftsprobehandler.c"
void
test_HandleFtsWalRepProbe(void **state)
{
bool expected_mirror_state = true;
will_return(IsMirrorUp, expected_mirror_state);
expect_any(initStringInfo, str);
will_be_called(initStringInfo);
expect_any(pq_beginmessage, buf);
expect_value(pq_beginmessage, msgtype, '\0');
will_be_called(pq_beginmessage);
ProbeResponse response;
response.IsMirrorUp = expected_mirror_state;
expect_any(pq_sendbytes, buf);
expect_memory(pq_sendbytes, data, &response, sizeof(response));
expect_value(pq_sendbytes, datalen, sizeof(ProbeResponse));
will_be_called(pq_sendbytes);
expect_any(pq_endmessage, buf);
will_be_called(pq_endmessage);
will_be_called(pq_flush);
HandleFtsWalRepProbe();
}
int
main(int argc, char* argv[])
{
cmockery_parse_arguments(argc, argv);
const UnitTest tests[] = {
unit_test(test_HandleFtsWalRepProbe)
};
return run_tests(tests);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册