about summary refs log tree commit diff stats
path: root/tests/test_cmd_account.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-12-15 23:51:29 +0000
committerJames Booth <boothj5@gmail.com>2013-12-15 23:51:29 +0000
commit4216949b2ea220b0e32fb740d7d7f871f42ab747 (patch)
tree27b9ccd61e66fe2062c057452374df33b8960459 /tests/test_cmd_account.c
parentb2f4570886dd5c69ccd62fe8d39b4a51b8df356f (diff)
downloadprofani-tty-4216949b2ea220b0e32fb740d7d7f871f42ab747.tar.gz
Added tests for "/account enable"
Diffstat (limited to 'tests/test_cmd_account.c')
-rw-r--r--tests/test_cmd_account.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index 6a6cb062..04b0e19a 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -165,3 +165,67 @@ void cmd_account_add_shows_message(void **state)
 
     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);
+}
ef='#n229'>229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256