mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added tests for "/account enable"
This commit is contained in:
parent
b2f4570886
commit
4216949b2e
@ -65,6 +65,7 @@ void accounts_free_account(ProfAccount *account)
|
|||||||
|
|
||||||
gboolean accounts_enable(const char * const name)
|
gboolean accounts_enable(const char * const name)
|
||||||
{
|
{
|
||||||
|
check_expected(name);
|
||||||
return (gboolean)mock();
|
return (gboolean)mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,3 +165,67 @@ void cmd_account_add_shows_message(void **state)
|
|||||||
|
|
||||||
free(help);
|
free(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmd_account_enable_shows_usage_when_no_arg(void **state)
|
||||||
|
{
|
||||||
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
|
help->usage = "some usage";
|
||||||
|
gchar *args[] = { "enable", NULL };
|
||||||
|
|
||||||
|
expect_string(cons_show, output, "Usage: some usage");
|
||||||
|
|
||||||
|
gboolean result = cmd_account(args, *help);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
|
free(help);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_account_enable_enables_account(void **state)
|
||||||
|
{
|
||||||
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
|
gchar *args[] = { "enable", "account_name" };
|
||||||
|
|
||||||
|
expect_string(accounts_enable, name, "account_name");
|
||||||
|
will_return(accounts_enable, TRUE);
|
||||||
|
|
||||||
|
expect_any_count(cons_show, output, 2);
|
||||||
|
|
||||||
|
gboolean result = cmd_account(args, *help);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
|
free(help);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_account_enable_shows_message_when_enabled(void **state)
|
||||||
|
{
|
||||||
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
|
gchar *args[] = { "enable", "account_name" };
|
||||||
|
|
||||||
|
expect_any(accounts_enable, name);
|
||||||
|
will_return(accounts_enable, TRUE);
|
||||||
|
|
||||||
|
expect_string(cons_show, output, "Account enabled.");
|
||||||
|
expect_string(cons_show, output, "");
|
||||||
|
|
||||||
|
gboolean result = cmd_account(args, *help);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
|
free(help);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
|
||||||
|
{
|
||||||
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
|
gchar *args[] = { "enable", "account_name" };
|
||||||
|
|
||||||
|
expect_any(accounts_enable, name);
|
||||||
|
will_return(accounts_enable, FALSE);
|
||||||
|
|
||||||
|
expect_string(cons_show, output, "No such account: account_name");
|
||||||
|
expect_string(cons_show, output, "");
|
||||||
|
|
||||||
|
gboolean result = cmd_account(args, *help);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
|
free(help);
|
||||||
|
}
|
||||||
|
@ -7,3 +7,7 @@ void cmd_account_show_shows_message_when_account_exists(void **state);
|
|||||||
void cmd_account_add_shows_usage_when_no_arg(void **state);
|
void cmd_account_add_shows_usage_when_no_arg(void **state);
|
||||||
void cmd_account_add_adds_account(void **state);
|
void cmd_account_add_adds_account(void **state);
|
||||||
void cmd_account_add_shows_message(void **state);
|
void cmd_account_add_shows_message(void **state);
|
||||||
|
void cmd_account_enable_shows_usage_when_no_arg(void **state);
|
||||||
|
void cmd_account_enable_enables_account(void **state);
|
||||||
|
void cmd_account_enable_shows_message_when_enabled(void **state);
|
||||||
|
void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state);
|
||||||
|
@ -37,6 +37,10 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test(cmd_account_add_shows_usage_when_no_arg),
|
unit_test(cmd_account_add_shows_usage_when_no_arg),
|
||||||
unit_test(cmd_account_add_adds_account),
|
unit_test(cmd_account_add_adds_account),
|
||||||
unit_test(cmd_account_add_shows_message),
|
unit_test(cmd_account_add_shows_message),
|
||||||
|
unit_test(cmd_account_enable_shows_usage_when_no_arg),
|
||||||
|
unit_test(cmd_account_enable_enables_account),
|
||||||
|
unit_test(cmd_account_enable_shows_message_when_enabled),
|
||||||
|
unit_test(cmd_account_enable_shows_message_when_account_doesnt_exist),
|
||||||
|
|
||||||
unit_test(cmd_rooms_shows_message_when_disconnected),
|
unit_test(cmd_rooms_shows_message_when_disconnected),
|
||||||
unit_test(cmd_rooms_shows_message_when_disconnecting),
|
unit_test(cmd_rooms_shows_message_when_disconnecting),
|
||||||
|
Loading…
Reference in New Issue
Block a user