about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-12-15 23:36:20 +0000
committerJames Booth <boothj5@gmail.com>2013-12-15 23:36:20 +0000
commit85629cb9a3eaf5a7c88abe4bc4de899828465590 (patch)
treebfc6f662d609cda859528d75206e4de5c158b6f8
parentbf0870afe4a73521262a5363409d4f8bbf471c62 (diff)
downloadprofani-tty-85629cb9a3eaf5a7c88abe4bc4de899828465590.tar.gz
Test "/account add <account>" adds account
-rw-r--r--tests/config/mock_accounts.c6
-rw-r--r--tests/test_cmd_account.c19
-rw-r--r--tests/test_cmd_account.h1
-rw-r--r--tests/testsuite.c1
4 files changed, 24 insertions, 3 deletions
diff --git a/tests/config/mock_accounts.c b/tests/config/mock_accounts.c
index 960cf211..d2a5e75e 100644
--- a/tests/config/mock_accounts.c
+++ b/tests/config/mock_accounts.c
@@ -41,7 +41,11 @@ char * accounts_find_enabled(char *prefix)
 
 void accounts_reset_all_search(void) {}
 void accounts_reset_enabled_search(void) {}
-void accounts_add(const char *jid, const char *altdomain) {}
+
+void accounts_add(const char *jid, const char *altdomain)
+{
+    check_expected(jid);
+}
 
 gchar** accounts_get_list(void)
 {
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index 842ad13f..f6f14366 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -88,7 +88,7 @@ void cmd_account_show_shows_usage_when_no_arg(void **state)
 void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
 {
     CommandHelp *help = malloc(sizeof(CommandHelp));
-    gchar *args[] = { "show", "account_name" };
+    gchar *args[] = { "show", "account_name", NULL };
 
     expect_string(accounts_get_account, name, "account_name");
     will_return(accounts_get_account, NULL);
@@ -105,7 +105,7 @@ void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
 void cmd_account_show_shows_message_when_account_exists(void **state)
 {
     CommandHelp *help = malloc(sizeof(CommandHelp));
-    gchar *args[] = { "show", "account_name" };
+    gchar *args[] = { "show", "account_name", NULL };
     ProfAccount *account = malloc(sizeof(ProfAccount));
 
     expect_string(accounts_get_account, name, "account_name");
@@ -134,3 +134,18 @@ void cmd_account_add_shows_usage_when_no_arg(void **state)
 
     free(help);
 }
+
+void cmd_account_add_adds_account(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "add", "new_account", NULL };
+
+    expect_string(accounts_add, jid, "new_account");
+
+    expect_any_count(cons_show, output, 2);
+
+    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 9b7a4f4b..be3a420d 100644
--- a/tests/test_cmd_account.h
+++ b/tests/test_cmd_account.h
@@ -5,3 +5,4 @@ void cmd_account_show_shows_usage_when_no_arg(void **state);
 void cmd_account_show_shows_message_when_account_does_not_exist(void **state);
 void cmd_account_show_shows_message_when_account_exists(void **state);
 void cmd_account_add_shows_usage_when_no_arg(void **state);
+void cmd_account_add_adds_account(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 2c6789be..cdf07b73 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -35,6 +35,7 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_account_show_shows_message_when_account_does_not_exist),
         unit_test(cmd_account_show_shows_message_when_account_exists),
         unit_test(cmd_account_add_shows_usage_when_no_arg),
+        unit_test(cmd_account_add_adds_account),
 
         unit_test(cmd_rooms_shows_message_when_disconnected),
         unit_test(cmd_rooms_shows_message_when_disconnecting),