about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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);
 }