1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added tests for connecting with account

This commit is contained in:
James Booth 2013-12-15 21:31:27 +00:00
parent cae2979a0b
commit 5ec2d3cf7c
4 changed files with 35 additions and 1 deletions

View File

@ -162,6 +162,8 @@ void cmd_connect_asks_password_when_not_in_account(void **state)
will_return(ui_ask_password, strdup("password"));
expect_any(cons_show, output);
expect_any(jabber_connect_with_account, account);
will_return(jabber_connect_with_account, JABBER_CONNECTING);
gboolean result = cmd_connect(args, *help);
@ -187,6 +189,8 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state)
will_return(accounts_create_full_jid, strdup("user@jabber.org/laptop"));
expect_string(cons_show, output, "Connecting with account jabber_org as user@jabber.org/laptop");
expect_any(jabber_connect_with_account, account);
will_return(jabber_connect_with_account, JABBER_CONNECTING);
gboolean result = cmd_connect(args, *help);
@ -194,5 +198,32 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state)
free(help);
free(account);
}
void cmd_connect_connects_with_account(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "jabber_org", NULL };
ProfAccount *account = malloc(sizeof(ProfAccount));
account->password = "password";
account->name = "jabber_org";
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_any(accounts_get_account, name);
will_return(accounts_get_account, account);
will_return(accounts_create_full_jid, strdup("user@jabber.org/laptop"));
expect_any(cons_show, output);
expect_memory(jabber_connect_with_account, account, account, sizeof(ProfAccount));
will_return(jabber_connect_with_account, JABBER_CONNECTING);
gboolean result = cmd_connect(args, *help);
assert_true(result);
free(help);
free(account);
}

View File

@ -8,3 +8,4 @@ void cmd_connect_fail_message(void **state);
void cmd_connect_lowercases_argument(void **state);
void cmd_connect_asks_password_when_not_in_account(void **state);
void cmd_connect_shows_message_when_connecting_with_account(void **state);
void cmd_connect_connects_with_account(void **state);

View File

@ -24,6 +24,7 @@ int main(int argc, char* argv[]) {
unit_test(cmd_connect_lowercases_argument),
unit_test(cmd_connect_asks_password_when_not_in_account),
unit_test(cmd_connect_shows_message_when_connecting_with_account),
unit_test(cmd_connect_connects_with_account),
unit_test(cmd_rooms_shows_message_when_disconnected),
unit_test(cmd_rooms_shows_message_when_disconnecting),

View File

@ -40,6 +40,7 @@ jabber_conn_status_t jabber_connect_with_details(const char * const jid,
jabber_conn_status_t jabber_connect_with_account(const ProfAccount * const account)
{
check_expected(account);
return (jabber_conn_status_t)mock();
}