about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--tests/config/mock_accounts.c14
-rw-r--r--tests/test_cmd_account.c82
-rw-r--r--tests/test_cmd_account.h4
-rw-r--r--tests/testsuite.c4
4 files changed, 102 insertions, 2 deletions
diff --git a/tests/config/mock_accounts.c b/tests/config/mock_accounts.c
index 294d2662..d5992822 100644
--- a/tests/config/mock_accounts.c
+++ b/tests/config/mock_accounts.c
@@ -113,8 +113,18 @@ void accounts_set_password(const char * const account_name, const char * const v
     check_expected(value);
 }
 
-void accounts_set_muc_service(const char * const account_name, const char * const value) {}
-void accounts_set_muc_nick(const char * const account_name, const char * const value) {}
+void accounts_set_muc_service(const char * const account_name, const char * const value)
+{
+    check_expected(account_name);
+    check_expected(value);
+}
+
+void accounts_set_muc_nick(const char * const account_name, const char * const value)
+{
+    check_expected(account_name);
+    check_expected(value);
+}
+
 void accounts_set_last_presence(const char * const account_name, const char * const value) {}
 void accounts_set_login_presence(const char * const account_name, const char * const value) {}
 
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index 5deece35..3d3a6bf5 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -643,3 +643,85 @@ void cmd_account_set_password_shows_message(void **state)
 
     free(help);
 }
+
+void cmd_account_set_muc_sets_muc(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "some usage";
+    gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(accounts_set_muc_service, account_name, "a_account");
+    expect_string(accounts_set_muc_service, value, "a_muc");
+
+    expect_any_count(cons_show, output, 2);
+    
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_muc_shows_message(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "some usage";
+    gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_any(accounts_set_muc_service, account_name);
+    expect_any(accounts_set_muc_service, value);
+
+    expect_string(cons_show, output, "Updated muc service for account a_account: a_muc");
+    expect_string(cons_show, output, "");
+    
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_nick_sets_nick(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "some usage";
+    gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(accounts_set_muc_nick, account_name, "a_account");
+    expect_string(accounts_set_muc_nick, value, "a_nick");
+
+    expect_any_count(cons_show, output, 2);
+    
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_nick_shows_message(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "some usage";
+    gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL };
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_any(accounts_set_muc_nick, account_name);
+    expect_any(accounts_set_muc_nick, value);
+
+    expect_string(cons_show, output, "Updated muc nick for account a_account: a_nick");
+    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 0355a73c..ccb2a16c 100644
--- a/tests/test_cmd_account.h
+++ b/tests/test_cmd_account.h
@@ -34,3 +34,7 @@ void cmd_account_set_resource_sets_resource(void **state);
 void cmd_account_set_resource_shows_message(void **state);
 void cmd_account_set_password_sets_password(void **state);
 void cmd_account_set_password_shows_message(void **state);
+void cmd_account_set_muc_sets_muc(void **state);
+void cmd_account_set_muc_shows_message(void **state);
+void cmd_account_set_nick_sets_nick(void **state);
+void cmd_account_set_nick_shows_message(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 6bff4361..d23f13d5 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -217,6 +217,10 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_account_set_resource_shows_message),
         unit_test(cmd_account_set_password_sets_password),
         unit_test(cmd_account_set_password_shows_message),
+        unit_test(cmd_account_set_muc_sets_muc),
+        unit_test(cmd_account_set_muc_shows_message),
+        unit_test(cmd_account_set_nick_sets_nick),
+        unit_test(cmd_account_set_nick_shows_message),
     };
     return run_tests(tests);
 }