diff options
-rw-r--r-- | tests/config/mock_accounts.c | 39 | ||||
-rw-r--r-- | tests/config/mock_accounts.h | 1 | ||||
-rw-r--r-- | tests/test_cmd_account.c | 22 | ||||
-rw-r--r-- | tests/test_cmd_account.h | 1 | ||||
-rw-r--r-- | tests/testsuite.c | 1 |
5 files changed, 63 insertions, 1 deletions
diff --git a/tests/config/mock_accounts.c b/tests/config/mock_accounts.c index a40d4a67..893a0449 100644 --- a/tests/config/mock_accounts.c +++ b/tests/config/mock_accounts.c @@ -189,6 +189,12 @@ _mock_accounts_set_priority_online(const char * const account_name, const gint v } static void +_stub_accounts_set_priority_online(const char * const account_name, const gint value) +{ + // do nothing +} + +static void _mock_accounts_set_priority_chat(const char * const account_name, const gint value) { check_expected(account_name); @@ -196,6 +202,12 @@ _mock_accounts_set_priority_chat(const char * const account_name, const gint val } static void +_stub_accounts_set_priority_chat(const char * const account_name, const gint value) +{ + // do nothing +} + +static void _mock_accounts_set_priority_away(const char * const account_name, const gint value) { check_expected(account_name); @@ -203,6 +215,12 @@ _mock_accounts_set_priority_away(const char * const account_name, const gint val } static void +_stub_accounts_set_priority_away(const char * const account_name, const gint value) +{ + // do nothing +} + +static void _mock_accounts_set_priority_xa(const char * const account_name, const gint value) { check_expected(account_name); @@ -210,12 +228,23 @@ _mock_accounts_set_priority_xa(const char * const account_name, const gint value } static void +_stub_accounts_set_priority_xa(const char * const account_name, const gint value) +{ + // do nothing +} + +static void _mock_accounts_set_priority_dnd(const char * const account_name, const gint value) { check_expected(account_name); check_expected(value); } +static void +_stub_accounts_set_priority_dnd(const char * const account_name, const gint value) +{ + // do nothing +} static void _mock_accounts_set_login_presence(const char * const account_name, const char * const value) @@ -380,6 +409,16 @@ mock_accounts_set_priorities(void) } void +stub_accounts_set_priorities(void) +{ + accounts_set_priority_online = _stub_accounts_set_priority_online; + accounts_set_priority_chat = _stub_accounts_set_priority_chat; + accounts_set_priority_away = _stub_accounts_set_priority_away; + accounts_set_priority_xa = _stub_accounts_set_priority_xa; + accounts_set_priority_dnd = _stub_accounts_set_priority_dnd; +} + +void mock_accounts_set_login_presence(void) { accounts_set_login_presence = _mock_accounts_set_login_presence; diff --git a/tests/config/mock_accounts.h b/tests/config/mock_accounts.h index 84bfcc0a..38c6ca94 100644 --- a/tests/config/mock_accounts.h +++ b/tests/config/mock_accounts.h @@ -79,6 +79,7 @@ void stub_accounts_set_muc_nick(void); void accounts_set_muc_nick_expect(char *account_name, char *nick); void mock_accounts_set_priorities(void); +void stub_accounts_set_priorities(void); void accounts_set_priority_online_expect(char *account_name, gint priority); void accounts_set_priority_chat_expect(char *account_name, gint priority); void accounts_set_priority_away_expect(char *account_name, gint priority); diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c index 6d7a6d85..204f0985 100644 --- a/tests/test_cmd_account.c +++ b/tests/test_cmd_account.c @@ -947,7 +947,27 @@ void cmd_account_set_dnd_priority_sets_preference(void **state) free(help); } -// test message shown when set +void cmd_account_set_online_priority_shows_message(void **state) +{ + mock_cons_show(); + mock_accounts_account_exists(); + stub_accounts_set_priorities(); + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { "set", "a_account", "online", "10", NULL }; + + accounts_account_exists_return(TRUE); + + mock_connection_status(JABBER_DISCONNECTED); + + expect_cons_show("Updated online priority for account a_account: 10"); + expect_cons_show(""); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); + +} // test invalid priority low // test invalid priority high // test presence updated when connected as account and current presence equals setting diff --git a/tests/test_cmd_account.h b/tests/test_cmd_account.h index 8d63dcbc..20376dad 100644 --- a/tests/test_cmd_account.h +++ b/tests/test_cmd_account.h @@ -50,3 +50,4 @@ void cmd_account_set_chat_priority_sets_preference(void **state); void cmd_account_set_away_priority_sets_preference(void **state); void cmd_account_set_xa_priority_sets_preference(void **state); void cmd_account_set_dnd_priority_sets_preference(void **state); +void cmd_account_set_online_priority_shows_message(void **state); diff --git a/tests/testsuite.c b/tests/testsuite.c index 2e8c2e30..189698a4 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -241,6 +241,7 @@ int main(int argc, char* argv[]) { unit_test(cmd_account_set_away_priority_sets_preference), unit_test(cmd_account_set_xa_priority_sets_preference), unit_test(cmd_account_set_dnd_priority_sets_preference), + unit_test(cmd_account_set_online_priority_shows_message), }; return run_tests(tests); } |