about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-02-16 19:20:55 +0000
committerJames Booth <boothj5@gmail.com>2014-02-16 19:20:55 +0000
commite048b3196ed87481fcbce3be32c70caf4af0e4ae (patch)
treea04ce404b6fbc2a64be129da67a1c26c72288796
parenta21ab6d4c8d9de9abce9dddd1d23668779ca15e7 (diff)
downloadprofani-tty-e048b3196ed87481fcbce3be32c70caf4af0e4ae.tar.gz
Added test for message when no connected /otr gen
-rw-r--r--tests/test_cmd_otr.c15
-rw-r--r--tests/test_cmd_otr.h1
-rw-r--r--tests/testsuite.c1
3 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_cmd_otr.c b/tests/test_cmd_otr.c
index 7d6e8adb..8f58590d 100644
--- a/tests/test_cmd_otr.c
+++ b/tests/test_cmd_otr.c
@@ -263,6 +263,21 @@ void cmd_otr_libver_shows_libotr_version(void **state)
     g_string_free(message, TRUE);
     free(help);
 }
+
+void cmd_otr_gen_shows_message_when_not_connected(void **state)
+{
+    mock_cons_show();
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "gen", NULL };
+
+    mock_connection_status(JABBER_DISCONNECTED);
+    expect_cons_show("You must be connected with an account to load OTR information.");
+
+    gboolean result = cmd_otr(args, *help);
+    assert_true(result);
+
+    free(help);
+}
 #else
 void cmd_otr_shows_message_when_otr_unsupported(void **state)
 {
diff --git a/tests/test_cmd_otr.h b/tests/test_cmd_otr.h
index 137d7e7d..1f8584d8 100644
--- a/tests/test_cmd_otr.h
+++ b/tests/test_cmd_otr.h
@@ -15,6 +15,7 @@ void cmd_otr_warn_shows_usage_when_invalid_arg(void **state);
 void cmd_otr_warn_on_enables_unencrypted_warning(void **state);
 void cmd_otr_warn_off_disables_unencrypted_warning(void **state);
 void cmd_otr_libver_shows_libotr_version(void **state);
+void cmd_otr_gen_shows_message_when_not_connected(void **state);
 #else
 void cmd_otr_shows_message_when_otr_unsupported(void **state);
 #endif
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 29a5dc4d..f8315832 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -456,6 +456,7 @@ int main(int argc, char* argv[]) {
             load_preferences,
             close_preferences),
         unit_test(cmd_otr_libver_shows_libotr_version),
+        unit_test(cmd_otr_gen_shows_message_when_not_connected),
 #else
         unit_test(cmd_otr_shows_message_when_otr_unsupported),
 #endif