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-17 23:17:02 +0000
committerJames Booth <boothj5@gmail.com>2013-12-17 23:17:02 +0000
commit76e7a8341bc4a38f1394eaa42dbe182e265e83d8 (patch)
treee42990e7e5ad724adbff7beb87466c01eefb80be /tests/test_cmd_account.c
parentd5a2e645bf2d5ab6852e45a5a5268759ed2c2b2a (diff)
downloadprofani-tty-76e7a8341bc4a38f1394eaa42dbe182e265e83d8.tar.gz
Added tests for "/account set status"
Diffstat (limited to 'tests/test_cmd_account.c')
-rw-r--r--tests/test_cmd_account.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index eae3fb0c..222ab476 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -710,3 +710,98 @@ void cmd_account_set_nick_shows_message(void **state)
 
     free(help);
 }
+
+void cmd_account_set_status_shows_message_when_invalid_status(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "set", "a_account", "status", "bad_status", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(cons_show, output, "Invalid status: bad_status");
+    expect_string(cons_show, output, "");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_status_sets_status_when_valid(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "set", "a_account", "status", "away", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(accounts_set_login_presence, account_name, "a_account");
+    expect_string(accounts_set_login_presence, value, "away");
+
+    expect_any_count(cons_show, output, 2);
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_status_sets_status_when_last(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "set", "a_account", "status", "last", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(accounts_set_login_presence, account_name, "a_account");
+    expect_string(accounts_set_login_presence, value, "last");
+
+    expect_any_count(cons_show, output, 2);
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_status_shows_message_when_set_valid(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "set", "a_account", "status", "away", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_any(accounts_set_login_presence, account_name);
+    expect_any(accounts_set_login_presence, value);
+
+    expect_string(cons_show, output, "Updated login status for account a_account: away");
+    expect_string(cons_show, output, "");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_status_shows_message_when_set_last(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "set", "a_account", "status", "last", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_any(accounts_set_login_presence, account_name);
+    expect_any(accounts_set_login_presence, value);
+
+    expect_string(cons_show, output, "Updated login status for account a_account: last");
+    expect_string(cons_show, output, "");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}