1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added tests for "/account set password"

This commit is contained in:
James Booth 2013-12-17 22:40:55 +00:00
parent 8adca66fa3
commit 3b2446c46a
4 changed files with 51 additions and 1 deletions

View File

@ -107,7 +107,12 @@ void accounts_set_resource(const char * const account_name, const char * const v
check_expected(value);
}
void accounts_set_password(const char * const account_name, const char * const value) {}
void accounts_set_password(const char * const account_name, const char * const value)
{
check_expected(account_name);
check_expected(value);
}
void accounts_set_muc_service(const char * const account_name, const char * const value) {}
void accounts_set_muc_nick(const char * const account_name, const char * const value) {}
void accounts_set_last_presence(const char * const account_name, const char * const value) {}

View File

@ -602,3 +602,44 @@ void cmd_account_set_resource_shows_message(void **state)
free(help);
}
void cmd_account_set_password_sets_password(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE);
expect_string(accounts_set_password, account_name, "a_account");
expect_string(accounts_set_password, value, "a_password");
expect_any_count(cons_show, output, 2);
gboolean result = cmd_account(args, *help);
assert_true(result);
free(help);
}
void cmd_account_set_password_shows_message(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE);
expect_any(accounts_set_password, account_name);
expect_any(accounts_set_password, value);
expect_string(cons_show, output, "Updated password for account a_account");
expect_string(cons_show, output, "");
gboolean result = cmd_account(args, *help);
assert_true(result);
free(help);
}

View File

@ -32,3 +32,5 @@ void cmd_account_set_server_sets_server(void **state);
void cmd_account_set_server_shows_message(void **state);
void cmd_account_set_resource_sets_resource(void **state);
void cmd_account_set_resource_shows_message(void **state);
void cmd_account_set_password_sets_password(void **state);
void cmd_account_set_password_shows_message(void **state);

View File

@ -215,6 +215,8 @@ int main(int argc, char* argv[]) {
unit_test(cmd_account_set_server_shows_message),
unit_test(cmd_account_set_resource_sets_resource),
unit_test(cmd_account_set_resource_shows_message),
unit_test(cmd_account_set_password_sets_password),
unit_test(cmd_account_set_password_shows_message),
};
return run_tests(tests);
}