mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 04:16:21 +00:00
refactor(tests): migrate functional tests to content-based stubbing and enable unconditionally
This commit is contained in:
@@ -18,6 +18,7 @@ char *config_orig;
|
||||
char *data_orig;
|
||||
|
||||
int fd = 0;
|
||||
int stub_port = 5230;
|
||||
|
||||
gboolean
|
||||
_create_dir(const char *name)
|
||||
@@ -138,8 +139,16 @@ prof_start(void)
|
||||
int
|
||||
init_prof_test(void **state)
|
||||
{
|
||||
if (stbbr_start(STBBR_LOGDEBUG ,5230, 0) != 0) {
|
||||
assert_true(FALSE);
|
||||
gboolean started = FALSE;
|
||||
for (int p = 5230; p < 5250; ++p) {
|
||||
if (stbbr_start(STBBR_LOGDEBUG, p, 0) == 0) {
|
||||
stub_port = p;
|
||||
started = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!started) {
|
||||
assert_true(FALSE); // could not start stabber on any port in range
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -157,7 +166,7 @@ init_prof_test(void **state)
|
||||
_create_logs_dir();
|
||||
|
||||
prof_start();
|
||||
assert_true(prof_output_exact("Profanity"));
|
||||
assert_true(prof_output_exact("CProof. Type /help for help information."));
|
||||
|
||||
// set UI options to make expect assertions faster and more reliable
|
||||
prof_input("/inpblock timeout 5");
|
||||
@@ -182,7 +191,7 @@ init_prof_test(void **state)
|
||||
prof_input("/time muc off");
|
||||
assert_true(prof_output_exact("MUC time display disabled."));
|
||||
prof_input("/time config off");
|
||||
assert_true(prof_output_exact("config time display disabled."));
|
||||
assert_true(prof_output_exact("Config time display disabled."));
|
||||
prof_input("/time private off");
|
||||
assert_true(prof_output_exact("Private chat time display disabled."));
|
||||
prof_input("/time xml off");
|
||||
@@ -209,7 +218,8 @@ prof_input(const char *input)
|
||||
{
|
||||
GString *inp_str = g_string_new(input);
|
||||
g_string_append(inp_str, "\r");
|
||||
write(fd, inp_str->str, inp_str->len);
|
||||
ssize_t _wn = write(fd, inp_str->str, inp_str->len);
|
||||
(void)_wn;
|
||||
g_string_free(inp_str, TRUE);
|
||||
}
|
||||
|
||||
@@ -241,6 +251,9 @@ prof_connect_with_roster(const char *roster)
|
||||
stbbr_for_query("jabber:iq:roster", roster_str->str);
|
||||
g_string_free(roster_str, TRUE);
|
||||
|
||||
// Set up stabber to expect password "password"
|
||||
stbbr_auth_passwd("password");
|
||||
|
||||
stbbr_for_id("prof_presence_1",
|
||||
"<presence id='prof_presence_1' lang='en' to='stabber@localhost/profanity' from='stabber@localhost/profanity'>"
|
||||
"<priority>0</priority>"
|
||||
@@ -248,7 +261,9 @@ prof_connect_with_roster(const char *roster)
|
||||
"</presence>"
|
||||
);
|
||||
|
||||
prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow");
|
||||
char connect_cmd[128];
|
||||
snprintf(connect_cmd, sizeof(connect_cmd), "/connect stabber@localhost server 127.0.0.1 port %d tls allow", stub_port);
|
||||
prof_input(connect_cmd);
|
||||
prof_input("password");
|
||||
|
||||
// Allow time for profanity to connect
|
||||
|
||||
Reference in New Issue
Block a user