about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-12-17 22:37:35 +0000
committerJames Booth <boothj5@gmail.com>2013-12-17 22:37:35 +0000
commit8adca66fa36e79725a56552a1fe7fc9d3f28f95b (patch)
treef7a8e6486f28e006ea13a27e2c86c3026d713d2f /tests
parent9b41c4ee3246fb110c44f2d9a178416228cd39e9 (diff)
downloadprofani-tty-8adca66fa36e79725a56552a1fe7fc9d3f28f95b.tar.gz
Added tests for "/account set resource"
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd_account.c41
-rw-r--r--tests/test_cmd_account.h2
-rw-r--r--tests/testsuite.c2
3 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index d8d9e25a..0b267659 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -561,3 +561,44 @@ void cmd_account_set_server_shows_message(void **state)
 
     free(help);
 }
+
+void cmd_account_set_resource_sets_resource(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "some usage";
+    gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(accounts_set_resource, account_name, "a_account");
+    expect_string(accounts_set_resource, value, "a_resource");
+
+    expect_any_count(cons_show, output, 2);
+    
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_resource_shows_message(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "some usage";
+    gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_any(accounts_set_resource, account_name);
+    expect_any(accounts_set_resource, value);
+
+    expect_string(cons_show, output, "Updated resource for account a_account: a_resource");
+    expect_string(cons_show, output, "");
+    
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
diff --git a/tests/test_cmd_account.h b/tests/test_cmd_account.h
index 3affd717..412f5774 100644
--- a/tests/test_cmd_account.h
+++ b/tests/test_cmd_account.h
@@ -30,3 +30,5 @@ void cmd_account_set_jid_sets_barejid(void **state);
 void cmd_account_set_jid_sets_resource(void **state);
 void cmd_account_set_server_sets_server(void **state);
 void cmd_account_set_server_shows_message(void **state);
+void cmd_account_set_resource_sets_resource(void **state);
+void cmd_account_set_resource_shows_message(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 487a32a6..9fc62c71 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -213,6 +213,8 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_account_set_jid_sets_resource),
         unit_test(cmd_account_set_server_sets_server),
         unit_test(cmd_account_set_server_shows_message),
+        unit_test(cmd_account_set_resource_sets_resource),
+        unit_test(cmd_account_set_resource_shows_message),
     };
     return run_tests(tests);
 }