mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added tests for "/account set status"
This commit is contained in:
parent
d5a2e645bf
commit
76e7a8341b
@ -126,7 +126,12 @@ void accounts_set_muc_nick(const char * const account_name, const char * const v
|
||||
}
|
||||
|
||||
void accounts_set_last_presence(const char * const account_name, const char * const value) {}
|
||||
void accounts_set_login_presence(const char * const account_name, const char * const value) {}
|
||||
|
||||
void accounts_set_login_presence(const char * const account_name, const char * const value)
|
||||
{
|
||||
check_expected(account_name);
|
||||
check_expected(value);
|
||||
}
|
||||
|
||||
resource_presence_t accounts_get_login_presence(const char * const account_name)
|
||||
{
|
||||
|
@ -710,3 +710,98 @@ void cmd_account_set_nick_shows_message(void **state)
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_set_status_shows_message_when_invalid_status(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "set", "a_account", "status", "bad_status", NULL };
|
||||
|
||||
expect_any(accounts_account_exists, account_name);
|
||||
will_return(accounts_account_exists, TRUE);
|
||||
|
||||
expect_string(cons_show, output, "Invalid status: bad_status");
|
||||
expect_string(cons_show, output, "");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_set_status_sets_status_when_valid(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "set", "a_account", "status", "away", NULL };
|
||||
|
||||
expect_any(accounts_account_exists, account_name);
|
||||
will_return(accounts_account_exists, TRUE);
|
||||
|
||||
expect_string(accounts_set_login_presence, account_name, "a_account");
|
||||
expect_string(accounts_set_login_presence, value, "away");
|
||||
|
||||
expect_any_count(cons_show, output, 2);
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_set_status_sets_status_when_last(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "set", "a_account", "status", "last", NULL };
|
||||
|
||||
expect_any(accounts_account_exists, account_name);
|
||||
will_return(accounts_account_exists, TRUE);
|
||||
|
||||
expect_string(accounts_set_login_presence, account_name, "a_account");
|
||||
expect_string(accounts_set_login_presence, value, "last");
|
||||
|
||||
expect_any_count(cons_show, output, 2);
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_set_status_shows_message_when_set_valid(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "set", "a_account", "status", "away", NULL };
|
||||
|
||||
expect_any(accounts_account_exists, account_name);
|
||||
will_return(accounts_account_exists, TRUE);
|
||||
|
||||
expect_any(accounts_set_login_presence, account_name);
|
||||
expect_any(accounts_set_login_presence, value);
|
||||
|
||||
expect_string(cons_show, output, "Updated login status for account a_account: away");
|
||||
expect_string(cons_show, output, "");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_set_status_shows_message_when_set_last(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "set", "a_account", "status", "last", NULL };
|
||||
|
||||
expect_any(accounts_account_exists, account_name);
|
||||
will_return(accounts_account_exists, TRUE);
|
||||
|
||||
expect_any(accounts_set_login_presence, account_name);
|
||||
expect_any(accounts_set_login_presence, value);
|
||||
|
||||
expect_string(cons_show, output, "Updated login status for account a_account: last");
|
||||
expect_string(cons_show, output, "");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
@ -38,3 +38,8 @@ void cmd_account_set_muc_sets_muc(void **state);
|
||||
void cmd_account_set_muc_shows_message(void **state);
|
||||
void cmd_account_set_nick_sets_nick(void **state);
|
||||
void cmd_account_set_nick_shows_message(void **state);
|
||||
void cmd_account_set_status_shows_message_when_invalid_status(void **state);
|
||||
void cmd_account_set_status_sets_status_when_valid(void **state);
|
||||
void cmd_account_set_status_sets_status_when_last(void **state);
|
||||
void cmd_account_set_status_shows_message_when_set_valid(void **state);
|
||||
void cmd_account_set_status_shows_message_when_set_last(void **state);
|
||||
|
@ -229,6 +229,11 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_account_set_muc_shows_message),
|
||||
unit_test(cmd_account_set_nick_sets_nick),
|
||||
unit_test(cmd_account_set_nick_shows_message),
|
||||
unit_test(cmd_account_set_status_shows_message_when_invalid_status),
|
||||
unit_test(cmd_account_set_status_sets_status_when_valid),
|
||||
unit_test(cmd_account_set_status_sets_status_when_last),
|
||||
unit_test(cmd_account_set_status_shows_message_when_set_valid),
|
||||
unit_test(cmd_account_set_status_shows_message_when_set_last),
|
||||
};
|
||||
return run_tests(tests);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user