mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Refactoring cmd_account tests
This commit is contained in:
parent
05bf9bb993
commit
71dbd7fd77
@ -52,7 +52,8 @@ gboolean accounts_enable(const char * const name)
|
||||
|
||||
gboolean accounts_disable(const char * const name)
|
||||
{
|
||||
return FALSE;
|
||||
check_expected(name);
|
||||
return (gboolean)mock();
|
||||
}
|
||||
|
||||
gboolean accounts_rename(const char * const account_name,
|
||||
|
@ -169,27 +169,8 @@ void cmd_account_enable_enables_account(void **state)
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "enable", "account_name", NULL };
|
||||
|
||||
will_return(accounts_enable, TRUE);
|
||||
|
||||
expect_string(accounts_enable, name, "account_name");
|
||||
expect_cons_show("Account enabled.");
|
||||
expect_cons_show("");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
/*
|
||||
void cmd_account_enable_shows_message_when_enabled(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
mock_accounts_enable();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "enable", "account_name", NULL };
|
||||
|
||||
accounts_enable_return(TRUE);
|
||||
will_return(accounts_enable, TRUE);
|
||||
|
||||
expect_cons_show("Account enabled.");
|
||||
expect_cons_show("");
|
||||
@ -202,12 +183,11 @@ void cmd_account_enable_shows_message_when_enabled(void **state)
|
||||
|
||||
void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
mock_accounts_enable();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "enable", "account_name", NULL };
|
||||
|
||||
accounts_enable_return(FALSE);
|
||||
expect_any(accounts_enable, name);
|
||||
will_return(accounts_enable, FALSE);
|
||||
|
||||
expect_cons_show("No such account: account_name");
|
||||
expect_cons_show("");
|
||||
@ -220,7 +200,6 @@ void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
|
||||
|
||||
void cmd_account_disable_shows_usage_when_no_arg(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "disable", NULL };
|
||||
@ -235,27 +214,11 @@ void cmd_account_disable_shows_usage_when_no_arg(void **state)
|
||||
|
||||
void cmd_account_disable_disables_account(void **state)
|
||||
{
|
||||
stub_cons_show();
|
||||
mock_accounts_disable();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "disable", "account_name", NULL };
|
||||
|
||||
accounts_disable_expect("account_name");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_disable_shows_message_when_disabled(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
mock_accounts_disable();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "disable", "account_name", NULL };
|
||||
|
||||
accounts_disable_return(TRUE);
|
||||
expect_string(accounts_disable, name, "account_name");
|
||||
will_return(accounts_disable, TRUE);
|
||||
|
||||
expect_cons_show("Account disabled.");
|
||||
expect_cons_show("");
|
||||
@ -268,12 +231,11 @@ void cmd_account_disable_shows_message_when_disabled(void **state)
|
||||
|
||||
void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
mock_accounts_disable();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "disable", "account_name", NULL };
|
||||
|
||||
accounts_disable_return(FALSE);
|
||||
expect_any(accounts_disable, name);
|
||||
will_return(accounts_disable, FALSE);
|
||||
|
||||
expect_cons_show("No such account: account_name");
|
||||
expect_cons_show("");
|
||||
@ -286,7 +248,6 @@ void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
|
||||
|
||||
void cmd_account_rename_shows_usage_when_no_args(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "rename", NULL };
|
||||
@ -301,7 +262,6 @@ void cmd_account_rename_shows_usage_when_no_args(void **state)
|
||||
|
||||
void cmd_account_rename_shows_usage_when_one_arg(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "rename", "original_name", NULL };
|
||||
@ -314,6 +274,7 @@ void cmd_account_rename_shows_usage_when_one_arg(void **state)
|
||||
free(help);
|
||||
}
|
||||
|
||||
/*
|
||||
void cmd_account_rename_renames_account(void **state)
|
||||
{
|
||||
stub_cons_show();
|
||||
|
@ -249,15 +249,13 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_account_add_adds_account),
|
||||
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_account_disable_shows_usage_when_no_arg),
|
||||
unit_test(cmd_account_disable_disables_account),
|
||||
unit_test(cmd_account_disable_shows_message_when_disabled),
|
||||
unit_test(cmd_account_disable_shows_message_when_account_doesnt_exist),
|
||||
unit_test(cmd_account_rename_shows_usage_when_no_args),
|
||||
unit_test(cmd_account_rename_shows_usage_when_one_arg),
|
||||
/*
|
||||
unit_test(cmd_account_rename_renames_account),
|
||||
unit_test(cmd_account_rename_shows_message_when_renamed),
|
||||
unit_test(cmd_account_rename_shows_message_when_not_renamed),
|
||||
|
Loading…
Reference in New Issue
Block a user