diff --git a/tests/config/mock_accounts.c b/tests/config/mock_accounts.c index 8cd8b93e..345e5978 100644 --- a/tests/config/mock_accounts.c +++ b/tests/config/mock_accounts.c @@ -95,7 +95,11 @@ void accounts_set_jid(const char * const account_name, const char * const value) check_expected(value); } -void accounts_set_server(const char * const account_name, const char * const value) {} +void accounts_set_server(const char * const account_name, const char * const value) +{ + check_expected(account_name); + check_expected(value); +} void accounts_set_resource(const char * const account_name, const char * const value) { diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c index 2e43bca6..d8d9e25a 100644 --- a/tests/test_cmd_account.c +++ b/tests/test_cmd_account.c @@ -520,3 +520,44 @@ void cmd_account_set_jid_sets_resource(void **state) free(help); } + +void cmd_account_set_server_sets_server(void **state) +{ + CommandHelp *help = malloc(sizeof(CommandHelp)); + help->usage = "some usage"; + gchar *args[] = { "set", "a_account", "server", "a_server", NULL }; + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_string(accounts_set_server, account_name, "a_account"); + expect_string(accounts_set_server, value, "a_server"); + + expect_any_count(cons_show, output, 2); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} + +void cmd_account_set_server_shows_message(void **state) +{ + CommandHelp *help = malloc(sizeof(CommandHelp)); + help->usage = "some usage"; + gchar *args[] = { "set", "a_account", "server", "a_server", NULL }; + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_any(accounts_set_server, account_name); + expect_any(accounts_set_server, value); + + expect_string(cons_show, output, "Updated server for account a_account: a_server"); + expect_string(cons_show, output, ""); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} diff --git a/tests/test_cmd_account.h b/tests/test_cmd_account.h index 62783609..3affd717 100644 --- a/tests/test_cmd_account.h +++ b/tests/test_cmd_account.h @@ -28,3 +28,5 @@ void cmd_account_set_shows_message_when_account_doesnt_exist(void **state); void cmd_account_set_jid_shows_message_for_malformed_jid(void **state); void cmd_account_set_jid_sets_barejid(void **state); void cmd_account_set_jid_sets_resource(void **state); +void cmd_account_set_server_sets_server(void **state); +void cmd_account_set_server_shows_message(void **state); diff --git a/tests/testsuite.c b/tests/testsuite.c index 44c014df..487a32a6 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -211,6 +211,8 @@ int main(int argc, char* argv[]) { unit_test(cmd_account_set_jid_shows_message_for_malformed_jid), unit_test(cmd_account_set_jid_sets_barejid), unit_test(cmd_account_set_jid_sets_resource), + unit_test(cmd_account_set_server_sets_server), + unit_test(cmd_account_set_server_shows_message), }; return run_tests(tests); }