about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorPeter Vilim <peterlvilim@users.noreply.github.com>2015-01-12 19:04:37 -0600
committerPeter Vilim <peterlvilim@users.noreply.github.com>2015-01-12 19:32:26 -0600
commitf6da9444794f6faa984f68c8f54849a170fe0e59 (patch)
tree964e8160eed1e2d3599bc4f1f68d4943aef8cca7 /tests
parent0cb548683c906eb7e48ddfccde4b95f671dea5fc (diff)
downloadprofani-tty-f6da9444794f6faa984f68c8f54849a170fe0e59.tar.gz
Add unit tests for eval_password
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd_account.c68
-rw-r--r--tests/test_cmd_account.h5
-rw-r--r--tests/testsuite.c3
3 files changed, 75 insertions, 1 deletions
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index 553b0d83..d02fc5ba 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -499,6 +499,74 @@ void cmd_account_set_password_sets_password(void **state)
     free(help);
 }
 
+void cmd_account_set_eval_password_sets_eval_password(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
+    ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
+    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(accounts_get_account, name, "a_account");
+    will_return(accounts_get_account, account);
+
+    expect_string(accounts_set_eval_password, account_name, "a_account");
+    expect_string(accounts_set_eval_password, value, "a_password");
+
+    expect_cons_show("Updated eval_password for account a_account");
+    expect_cons_show("");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_password_when_eval_password_set(void **state) {
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
+    ProfAccount *account = account_new("a_account", NULL, NULL, "a_password",
+    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(accounts_get_account, name, "a_account");
+    will_return(accounts_get_account, account);
+
+    expect_cons_show("Cannot set password when eval_password is set.");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_account_set_eval_password_when_password_set(void **state) {
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
+    ProfAccount *account = account_new("a_account", NULL, "a_password", NULL,
+    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+
+
+    expect_any(accounts_account_exists, account_name);
+    will_return(accounts_account_exists, TRUE);
+
+    expect_string(accounts_get_account, name, "a_account");
+    will_return(accounts_get_account, account);
+
+    expect_cons_show("Cannot set eval_password when password is set.");
+
+    gboolean result = cmd_account(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
 void cmd_account_set_muc_sets_muc(void **state)
 {
     CommandHelp *help = malloc(sizeof(CommandHelp));
diff --git a/tests/test_cmd_account.h b/tests/test_cmd_account.h
index d7fc6266..91bd1e70 100644
--- a/tests/test_cmd_account.h
+++ b/tests/test_cmd_account.h
@@ -26,6 +26,9 @@ void cmd_account_set_jid_sets_resource(void **state);
 void cmd_account_set_server_sets_server(void **state);
 void cmd_account_set_resource_sets_resource(void **state);
 void cmd_account_set_password_sets_password(void **state);
+void cmd_account_set_eval_password_sets_eval_password(void **state);
+void cmd_account_set_password_when_eval_password_set(void **state);
+void cmd_account_set_eval_password_when_password_set(void **state);
 void cmd_account_set_muc_sets_muc(void **state);
 void cmd_account_set_nick_sets_nick(void **state);
 void cmd_account_show_message_for_missing_otr_policy(void **state);
@@ -49,4 +52,4 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
 void cmd_account_clear_shows_usage_when_no_args(void **state);
 void cmd_account_clear_shows_usage_when_one_arg(void **state);
 void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state);
-void cmd_account_clear_shows_message_when_invalid_property(void **state);
\ No newline at end of file
+void cmd_account_clear_shows_message_when_invalid_property(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index fb439331..1c879a4f 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -316,6 +316,9 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_account_set_server_sets_server),
         unit_test(cmd_account_set_resource_sets_resource),
         unit_test(cmd_account_set_password_sets_password),
+        unit_test(cmd_account_set_eval_password_sets_eval_password),
+        unit_test(cmd_account_set_password_when_eval_password_set),
+        unit_test(cmd_account_set_eval_password_when_password_set),
         unit_test(cmd_account_set_muc_sets_muc),
         unit_test(cmd_account_set_nick_sets_nick),
         unit_test(cmd_account_show_message_for_missing_otr_policy),