about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-12-15 23:07:53 +0000
committerJames Booth <boothj5@gmail.com>2013-12-15 23:07:53 +0000
commit6f060b583ee88f9d9c8f56b7a3b74e558462c3db (patch)
tree354a6986a474f88b24493ac603cd493bc7591930
parent683da12c3aae53bb02ede52c924300580be9cc80 (diff)
downloadprofani-tty-6f060b583ee88f9d9c8f56b7a3b74e558462c3db.tar.gz
Test "/account list"
-rw-r--r--tests/test_cmd_account.c25
-rw-r--r--tests/test_cmd_account.h1
-rw-r--r--tests/testsuite.c1
-rw-r--r--tests/ui/mock_ui.c7
4 files changed, 32 insertions, 2 deletions
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index a857ca1c..33ba348b 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -7,6 +7,7 @@
 #include <glib.h>
 
 #include "xmpp/xmpp.h"
+#include "ui/ui.h"
 #include "command/commands.h"
 
 void cmd_account_shows_usage_when_not_connected_and_no_args(void **state)
@@ -32,7 +33,7 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state)
     gchar *args[] = { NULL };
 
     will_return(jabber_get_connection_status, JABBER_CONNECTED);
-    
+
     will_return(jabber_get_account_name, "account_name");
 
     expect_string(accounts_get_account, name, "account_name");
@@ -46,4 +47,26 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state)
     assert_true(result);
 
     free(help);
+    free(account);
+}
+
+void cmd_account_list_shows_accounts(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "list" };
+
+    gchar **accounts = malloc(sizeof(gchar *) * 4);
+    accounts[0] = strdup("account1");
+    accounts[1] = strdup("account2");
+    accounts[2] = strdup("account3");
+    accounts[3] = NULL;
+
+    will_return(accounts_get_list, accounts);
+
+    expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts));
+
+    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 30944fe4..2232b6aa 100644
--- a/tests/test_cmd_account.h
+++ b/tests/test_cmd_account.h
@@ -1,2 +1,3 @@
 void cmd_account_shows_usage_when_not_connected_and_no_args(void **state);
 void cmd_account_shows_account_when_connected_and_no_args(void **state);
+void cmd_account_list_shows_accounts(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 73c54014..f594a35e 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -30,6 +30,7 @@ int main(int argc, char* argv[]) {
 
         unit_test(cmd_account_shows_usage_when_not_connected_and_no_args),
         unit_test(cmd_account_shows_account_when_connected_and_no_args),
+        unit_test(cmd_account_list_shows_accounts),
 
         unit_test(cmd_rooms_shows_message_when_disconnected),
         unit_test(cmd_rooms_shows_message_when_disconnecting),
diff --git a/tests/ui/mock_ui.c b/tests/ui/mock_ui.c
index 5d83bcea..6e3e190c 100644
--- a/tests/ui/mock_ui.c
+++ b/tests/ui/mock_ui.c
@@ -250,7 +250,12 @@ void cons_show_login_success(ProfAccount *account) {}
 void cons_show_software_version(const char * const jid,
     const char * const presence, const char * const name,
     const char * const version, const char * const os) {}
-void cons_show_account_list(gchar **accounts) {}
+
+void cons_show_account_list(gchar **accounts)
+{
+    check_expected(accounts);
+}
+
 void cons_show_room_list(GSList *room, const char * const conference_node) {}
 void cons_show_bookmarks(const GList *list) {}
 void cons_show_disco_items(GSList *items, const char * const jid) {}