about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--tests/config/stub_accounts.c3
-rw-r--r--tests/test_cmd_account.c55
-rw-r--r--tests/testsuite.c4
3 files changed, 11 insertions, 51 deletions
diff --git a/tests/config/stub_accounts.c b/tests/config/stub_accounts.c
index 78f0c44e..fbe4b604 100644
--- a/tests/config/stub_accounts.c
+++ b/tests/config/stub_accounts.c
@@ -52,7 +52,8 @@ gboolean accounts_enable(const char * const name)
 
 gboolean accounts_disable(const char * const name)
 {
-    return FALSE;
+    check_expected(name);
+    return (gboolean)mock();
 }
 
 gboolean accounts_rename(const char * const account_name,
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c
index a76d50d3..21f7e0f2 100644
--- a/tests/test_cmd_account.c
+++ b/tests/test_cmd_account.c
@@ -169,27 +169,8 @@ void cmd_account_enable_enables_account(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "enable", "account_name", NULL };
 
-    will_return(accounts_enable, TRUE);
-
     expect_string(accounts_enable, name, "account_name");
-    expect_cons_show("Account enabled.");
-    expect_cons_show("");
-
-    gboolean result = cmd_account(args, *help);
-    assert_true(result);
-
-    free(help);
-}
-
-/*
-void cmd_account_enable_shows_message_when_enabled(void **state)
-{
-    mock_cons_show();
-    mock_accounts_enable();
-    CommandHelp *help = malloc(sizeof(CommandHelp));
-    gchar *args[] = { "enable", "account_name", NULL };
-
-    accounts_enable_return(TRUE);
+    will_return(accounts_enable, TRUE);
 
     expect_cons_show("Account enabled.");
     expect_cons_show("");
@@ -202,12 +183,11 @@ void cmd_account_enable_shows_message_when_enabled(void **state)
 
 void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
 {
-    mock_cons_show();
-    mock_accounts_enable();
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "enable", "account_name", NULL };
 
-    accounts_enable_return(FALSE);
+    expect_any(accounts_enable, name);
+    will_return(accounts_enable, FALSE);
 
     expect_cons_show("No such account: account_name");
     expect_cons_show("");
@@ -220,7 +200,6 @@ void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
 
 void cmd_account_disable_shows_usage_when_no_arg(void **state)
 {
-    mock_cons_show();
     CommandHelp *help = malloc(sizeof(CommandHelp));
     help->usage = "some usage";
     gchar *args[] = { "disable", NULL };
@@ -235,27 +214,11 @@ void cmd_account_disable_shows_usage_when_no_arg(void **state)
 
 void cmd_account_disable_disables_account(void **state)
 {
-    stub_cons_show();
-    mock_accounts_disable();
-    CommandHelp *help = malloc(sizeof(CommandHelp));
-    gchar *args[] = { "disable", "account_name", NULL };
-
-    accounts_disable_expect("account_name");
-
-    gboolean result = cmd_account(args, *help);
-    assert_true(result);
-
-    free(help);
-}
-
-void cmd_account_disable_shows_message_when_disabled(void **state)
-{
-    mock_cons_show();
-    mock_accounts_disable();
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "disable", "account_name", NULL };
 
-    accounts_disable_return(TRUE);
+    expect_string(accounts_disable, name, "account_name");
+    will_return(accounts_disable, TRUE);
 
     expect_cons_show("Account disabled.");
     expect_cons_show("");
@@ -268,12 +231,11 @@ void cmd_account_disable_shows_message_when_disabled(void **state)
 
 void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
 {
-    mock_cons_show();
-    mock_accounts_disable();
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "disable", "account_name", NULL };
 
-    accounts_disable_return(FALSE);
+    expect_any(accounts_disable, name);
+    will_return(accounts_disable, FALSE);
 
     expect_cons_show("No such account: account_name");
     expect_cons_show("");
@@ -286,7 +248,6 @@ void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
 
 void cmd_account_rename_shows_usage_when_no_args(void **state)
 {
-    mock_cons_show();
     CommandHelp *help = malloc(sizeof(CommandHelp));
     help->usage = "some usage";
     gchar *args[] = { "rename", NULL };
@@ -301,7 +262,6 @@ void cmd_account_rename_shows_usage_when_no_args(void **state)
 
 void cmd_account_rename_shows_usage_when_one_arg(void **state)
 {
-    mock_cons_show();
     CommandHelp *help = malloc(sizeof(CommandHelp));
     help->usage = "some usage";
     gchar *args[] = { "rename", "original_name", NULL };
@@ -314,6 +274,7 @@ void cmd_account_rename_shows_usage_when_one_arg(void **state)
     free(help);
 }
 
+/*
 void cmd_account_rename_renames_account(void **state)
 {
     stub_cons_show();
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 419a426f..7bd654cb 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -249,15 +249,13 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_account_add_adds_account),
         unit_test(cmd_account_enable_shows_usage_when_no_arg),
         unit_test(cmd_account_enable_enables_account),
-/*
-        unit_test(cmd_account_enable_shows_message_when_enabled),
         unit_test(cmd_account_enable_shows_message_when_account_doesnt_exist),
         unit_test(cmd_account_disable_shows_usage_when_no_arg),
         unit_test(cmd_account_disable_disables_account),
-        unit_test(cmd_account_disable_shows_message_when_disabled),
         unit_test(cmd_account_disable_shows_message_when_account_doesnt_exist),
         unit_test(cmd_account_rename_shows_usage_when_no_args),
         unit_test(cmd_account_rename_shows_usage_when_one_arg),
+/*
         unit_test(cmd_account_rename_renames_account),
         unit_test(cmd_account_rename_shows_message_when_renamed),
         unit_test(cmd_account_rename_shows_message_when_not_renamed),