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-27 14:35:31 +0000
committerJames Booth <boothj5@gmail.com>2013-12-27 14:35:31 +0000
commit122fe09c6153f0e368a1615e110a3458f24b52e2 (patch)
tree28f82171a60b8be79463dd8a6496a39122a3e7ec /tests/test_cmd_account.c
parent6d6bc67d5c70f4e43dd1eb543f58767de119ea8a (diff)
downloadprofani-tty-122fe09c6153f0e368a1615e110a3458f24b52e2.tar.gz
Added tests for "/account clear <property>"
Diffstat (limited to 'tests/test_cmd_account.c')
-rw-r--r--tests/test_cmd_account.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index c924c6ee..5de766e2 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -1057,3 +1057,85 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
 
     free(help);
 }
+
+void cmd_account_clear_shows_usage_when_no_args(void **state)
+{
+    mock_cons_show();
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "some usage";
+    gchar *args[] = { "clear", NULL };
+
+    expect_cons_show("Usage: some usage");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_clear_shows_usage_when_one_arg(void **state)
+{
+    mock_cons_show();
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "some usage";
+    gchar *args[] = { "clear", "a_account", NULL };
+
+    expect_cons_show("Usage: some usage");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_clear_checks_account_exists(void **state)
+{
+    stub_cons_show();
+    mock_accounts_account_exists();
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "clear", "a_account", "a_property", NULL };
+
+    accounts_account_exists_expect("a_account");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state)
+{
+    mock_cons_show();
+    mock_accounts_account_exists();
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "clear", "a_account", "a_property", NULL };
+
+    accounts_account_exists_return(FALSE);
+
+    expect_cons_show("Account a_account doesn't exist");
+    expect_cons_show("");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_clear_shows_message_when_invalid_property(void **state)
+{
+    mock_cons_show();
+    mock_accounts_account_exists();
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "clear", "a_account", "badproperty", NULL };
+
+    accounts_account_exists_return(TRUE);
+
+    expect_cons_show("Invalid property: badproperty");
+    expect_cons_show("");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+    
+}