about summary refs log tree commit diff stats
path: root/tests/test_cmd_account.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-12-24 14:41:33 +0000
committerJames Booth <boothj5@gmail.com>2014-12-24 14:41:33 +0000
commit71dbd7fd776126825960ce27915f80ed10c1cdc1 (patch)
tree39458c4e1d00fd63fbad0b7471913253c81ba5c0 /tests/test_cmd_account.c
parent05bf9bb9932e0ce7caeb1b44fc5403474dfaf9e1 (diff)
downloadprofani-tty-71dbd7fd776126825960ce27915f80ed10c1cdc1.tar.gz
Refactoring cmd_account tests
Diffstat (limited to 'tests/test_cmd_account.c')
-rw-r--r--tests/test_cmd_account.c55
1 files changed, 8 insertions, 47 deletions
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();