Added mock log module

This commit is contained in:
James Booth
2013-12-15 19:56:48 +00:00
parent 079ea5304b
commit 7842b0d1fc
6 changed files with 127 additions and 2 deletions

View File

@@ -67,3 +67,55 @@ void cmd_connect_when_no_account(void **state)
free(help);
}
void cmd_connect_with_altdomain_when_provided(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "altdomain" };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_string(cons_show, output, "Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org");
expect_string(jabber_connect_with_details, passwd, "password");
expect_string(jabber_connect_with_details, altdomain, "altdomain");
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(args, *help);
assert_true(result);
free(help);
}
void cmd_connect_fail_message(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "altdomain" };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_string(cons_show, output, "Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org");
expect_string(jabber_connect_with_details, passwd, "password");
expect_string(jabber_connect_with_details, altdomain, "altdomain");
will_return(jabber_connect_with_details, JABBER_DISCONNECTED);
expect_string(cons_show_error, output, "Connection attempt for user@server.org failed.");
gboolean result = cmd_connect(args, *help);
assert_true(result);
free(help);
}