From cae2979a0b5601ae7c1b39a5b28f4ceb77218bfa Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 15 Dec 2013 21:23:58 +0000 Subject: [PATCH] Added test for message when connecting via account --- tests/test_cmd_connect.c | 26 ++++++++++++++++++++++++++ tests/test_cmd_connect.h | 1 + tests/testsuite.c | 1 + 3 files changed, 28 insertions(+) diff --git a/tests/test_cmd_connect.c b/tests/test_cmd_connect.c index e07543f8..ad76da79 100644 --- a/tests/test_cmd_connect.c +++ b/tests/test_cmd_connect.c @@ -170,3 +170,29 @@ void cmd_connect_asks_password_when_not_in_account(void **state) free(help); free(account); } + +void cmd_connect_shows_message_when_connecting_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_string(cons_show, output, "Connecting with account jabber_org as user@jabber.org/laptop"); + will_return(jabber_connect_with_account, JABBER_CONNECTING); + + gboolean result = cmd_connect(args, *help); + assert_true(result); + + free(help); + free(account); + +} diff --git a/tests/test_cmd_connect.h b/tests/test_cmd_connect.h index 5349442b..9bb525cf 100644 --- a/tests/test_cmd_connect.h +++ b/tests/test_cmd_connect.h @@ -7,3 +7,4 @@ void cmd_connect_with_altdomain_when_provided(void **state); 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); diff --git a/tests/testsuite.c b/tests/testsuite.c index b88037e2..1c6c1d0a 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -23,6 +23,7 @@ int main(int argc, char* argv[]) { unit_test(cmd_connect_fail_message), 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_rooms_shows_message_when_disconnected), unit_test(cmd_rooms_shows_message_when_disconnecting),