diff options
author | James Booth <boothj5@gmail.com> | 2013-12-16 00:12:07 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-12-16 00:12:07 +0000 |
commit | e14b4ef558ccec2f77a42a192b74b0eba0cf541a (patch) | |
tree | 226cc465027ae3aeab2c6c03872f6e535e2fa615 /tests/test_cmd_account.c | |
parent | 3c0bbed7178168d9be2cc6a6e120994ba2d0b96b (diff) | |
download | profani-tty-e14b4ef558ccec2f77a42a192b74b0eba0cf541a.tar.gz |
Added tests for "/account rename"
Diffstat (limited to 'tests/test_cmd_account.c')
-rw-r--r-- | tests/test_cmd_account.c | 93 |
1 files changed, 87 insertions, 6 deletions
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c index a20111f1..b17d7b03 100644 --- a/tests/test_cmd_account.c +++ b/tests/test_cmd_account.c @@ -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); +} |