1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-29 19:56:07 -04:00

Added tests for "/account set server"

This commit is contained in:
James Booth 2013-12-17 22:33:49 +00:00
parent 52f6ad6fe1
commit 9b41c4ee32
4 changed files with 50 additions and 1 deletions

View File

@ -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)
{

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}