about summary refs log tree commit diff stats
path: root/tests/test_cmd_connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cmd_connect.c')
-rw-r--r--tests/test_cmd_connect.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test_cmd_connect.c b/tests/test_cmd_connect.c
index 2a09815f..0092d5e4 100644
--- a/tests/test_cmd_connect.c
+++ b/tests/test_cmd_connect.c
@@ -67,3 +67,55 @@ void cmd_connect_when_no_account(void **state)
 
     free(help);
 }
+
+void cmd_connect_with_altdomain_when_provided(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "user@server.org", "altdomain" };
+
+    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
+    
+    expect_string(accounts_get_account, name, "user@server.org");
+    will_return(accounts_get_account, NULL);
+
+    will_return(ui_ask_password, strdup("password"));
+
+    expect_string(cons_show, output, "Connecting as user@server.org");
+
+    expect_string(jabber_connect_with_details, jid, "user@server.org");
+    expect_string(jabber_connect_with_details, passwd, "password");
+    expect_string(jabber_connect_with_details, altdomain, "altdomain");
+    will_return(jabber_connect_with_details, JABBER_CONNECTING);
+
+    gboolean result = cmd_connect(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_connect_fail_message(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "user@server.org", "altdomain" };
+
+    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
+    
+    expect_string(accounts_get_account, name, "user@server.org");
+    will_return(accounts_get_account, NULL);
+
+    will_return(ui_ask_password, strdup("password"));
+
+    expect_string(cons_show, output, "Connecting as user@server.org");
+
+    expect_string(jabber_connect_with_details, jid, "user@server.org");
+    expect_string(jabber_connect_with_details, passwd, "password");
+    expect_string(jabber_connect_with_details, altdomain, "altdomain");
+    will_return(jabber_connect_with_details, JABBER_DISCONNECTED);
+
+    expect_string(cons_show_error, output, "Connection attempt for user@server.org failed.");
+
+    gboolean result = cmd_connect(args, *help);
+    assert_true(result);
+
+    free(help);
+}