mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added tests for "/account rename"
This commit is contained in:
parent
3c0bbed717
commit
e14b4ef558
@ -78,6 +78,8 @@ gboolean accounts_disable(const char * const name)
|
||||
gboolean accounts_rename(const char * const account_name,
|
||||
const char * const new_name)
|
||||
{
|
||||
check_expected(account_name);
|
||||
check_expected(new_name);
|
||||
return (gboolean)mock();
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ void cmd_account_enable_shows_usage_when_no_arg(void **state)
|
||||
void cmd_account_enable_enables_account(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "enable", "account_name" };
|
||||
gchar *args[] = { "enable", "account_name", NULL };
|
||||
|
||||
expect_string(accounts_enable, name, "account_name");
|
||||
will_return(accounts_enable, TRUE);
|
||||
@ -199,7 +199,7 @@ void cmd_account_enable_enables_account(void **state)
|
||||
void cmd_account_enable_shows_message_when_enabled(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "enable", "account_name" };
|
||||
gchar *args[] = { "enable", "account_name", NULL };
|
||||
|
||||
expect_any(accounts_enable, name);
|
||||
will_return(accounts_enable, TRUE);
|
||||
@ -216,7 +216,7 @@ void cmd_account_enable_shows_message_when_enabled(void **state)
|
||||
void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "enable", "account_name" };
|
||||
gchar *args[] = { "enable", "account_name", NULL };
|
||||
|
||||
expect_any(accounts_enable, name);
|
||||
will_return(accounts_enable, FALSE);
|
||||
@ -247,7 +247,7 @@ void cmd_account_disable_shows_usage_when_no_arg(void **state)
|
||||
void cmd_account_disable_disables_account(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "disable", "account_name" };
|
||||
gchar *args[] = { "disable", "account_name", NULL };
|
||||
|
||||
expect_string(accounts_disable, name, "account_name");
|
||||
will_return(accounts_disable, TRUE);
|
||||
@ -263,7 +263,7 @@ void cmd_account_disable_disables_account(void **state)
|
||||
void cmd_account_disable_shows_message_when_disabled(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "disable", "account_name" };
|
||||
gchar *args[] = { "disable", "account_name", NULL };
|
||||
|
||||
expect_any(accounts_disable, name);
|
||||
will_return(accounts_disable, TRUE);
|
||||
@ -280,7 +280,7 @@ void cmd_account_disable_shows_message_when_disabled(void **state)
|
||||
void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "disable", "account_name" };
|
||||
gchar *args[] = { "disable", "account_name", NULL };
|
||||
|
||||
expect_any(accounts_disable, name);
|
||||
will_return(accounts_disable, FALSE);
|
||||
@ -293,3 +293,84 @@ void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_rename_shows_usage_when_no_args(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "rename", NULL };
|
||||
|
||||
expect_string(cons_show, output, "Usage: some usage");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_rename_shows_usage_when_one_arg(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "rename", "original_name", NULL };
|
||||
|
||||
expect_string(cons_show, output, "Usage: some usage");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_rename_renames_account(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "rename", "original_name", "new_name", NULL };
|
||||
|
||||
expect_string(accounts_rename, account_name, "original_name");
|
||||
expect_string(accounts_rename, new_name, "new_name");
|
||||
will_return(accounts_rename, TRUE);
|
||||
|
||||
expect_any_count(cons_show, output, 2);
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_rename_shows_message_when_renamed(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "rename", "original_name", "new_name", NULL };
|
||||
|
||||
expect_string(accounts_rename, account_name, "original_name");
|
||||
expect_string(accounts_rename, new_name, "new_name");
|
||||
will_return(accounts_rename, TRUE);
|
||||
|
||||
expect_string(cons_show, output, "Account renamed.");
|
||||
expect_string(cons_show, output, "");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_account_rename_shows_message_when_not_renamed(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "rename", "original_name", "new_name", NULL };
|
||||
|
||||
expect_string(accounts_rename, account_name, "original_name");
|
||||
expect_string(accounts_rename, new_name, "new_name");
|
||||
will_return(accounts_rename, FALSE);
|
||||
|
||||
expect_string(cons_show, output, "Either account original_name doesn't exist, or account new_name already exists.");
|
||||
expect_string(cons_show, output, "");
|
||||
|
||||
gboolean result = cmd_account(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
@ -15,3 +15,8 @@ void cmd_account_disable_shows_usage_when_no_arg(void **state);
|
||||
void cmd_account_disable_disables_account(void **state);
|
||||
void cmd_account_disable_shows_message_when_disabled(void **state);
|
||||
void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state);
|
||||
void cmd_account_rename_shows_usage_when_no_args(void **state);
|
||||
void cmd_account_rename_shows_usage_when_one_arg(void **state);
|
||||
void cmd_account_rename_renames_account(void **state);
|
||||
void cmd_account_rename_shows_message_when_renamed(void **state);
|
||||
void cmd_account_rename_shows_message_when_not_renamed(void **state);
|
||||
|
@ -45,6 +45,11 @@ int main(int argc, char* argv[]) {
|
||||
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),
|
||||
|
||||
unit_test(cmd_rooms_shows_message_when_disconnected),
|
||||
unit_test(cmd_rooms_shows_message_when_disconnecting),
|
||||
|
Loading…
x
Reference in New Issue
Block a user