From 76e7a8341bc4a38f1394eaa42dbe182e265e83d8 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 17 Dec 2013 23:17:02 +0000 Subject: Added tests for "/account set status" --- tests/test_cmd_account.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'tests/test_cmd_account.c') diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c index eae3fb0c..222ab476 100644 --- a/tests/test_cmd_account.c +++ b/tests/test_cmd_account.c @@ -710,3 +710,98 @@ void cmd_account_set_nick_shows_message(void **state) free(help); } + +void cmd_account_set_status_shows_message_when_invalid_status(void **state) +{ + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { "set", "a_account", "status", "bad_status", NULL }; + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_string(cons_show, output, "Invalid status: bad_status"); + expect_string(cons_show, output, ""); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} + +void cmd_account_set_status_sets_status_when_valid(void **state) +{ + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { "set", "a_account", "status", "away", NULL }; + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_string(accounts_set_login_presence, account_name, "a_account"); + expect_string(accounts_set_login_presence, value, "away"); + + expect_any_count(cons_show, output, 2); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} + +void cmd_account_set_status_sets_status_when_last(void **state) +{ + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { "set", "a_account", "status", "last", NULL }; + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_string(accounts_set_login_presence, account_name, "a_account"); + expect_string(accounts_set_login_presence, value, "last"); + + expect_any_count(cons_show, output, 2); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} + +void cmd_account_set_status_shows_message_when_set_valid(void **state) +{ + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { "set", "a_account", "status", "away", NULL }; + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_any(accounts_set_login_presence, account_name); + expect_any(accounts_set_login_presence, value); + + expect_string(cons_show, output, "Updated login status for account a_account: away"); + expect_string(cons_show, output, ""); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} + +void cmd_account_set_status_shows_message_when_set_last(void **state) +{ + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { "set", "a_account", "status", "last", NULL }; + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_any(accounts_set_login_presence, account_name); + expect_any(accounts_set_login_presence, value); + + expect_string(cons_show, output, "Updated login status for account a_account: last"); + expect_string(cons_show, output, ""); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} -- cgit 1.4.1-2-gfad0