From b466809245f125f4c85c85e72cce0d167315aea8 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 26 Dec 2013 15:17:46 +0000 Subject: Added test for showing message when changing priority --- tests/config/mock_accounts.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/config/mock_accounts.h | 1 + tests/test_cmd_account.c | 22 +++++++++++++++++++++- tests/test_cmd_account.h | 1 + tests/testsuite.c | 1 + 5 files changed, 63 insertions(+), 1 deletion(-) 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 @@ -188,6 +188,12 @@ _mock_accounts_set_priority_online(const char * const account_name, const gint v check_expected(value); } +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) { @@ -195,6 +201,12 @@ _mock_accounts_set_priority_chat(const char * const account_name, const gint val check_expected(value); } +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) { @@ -202,6 +214,12 @@ _mock_accounts_set_priority_away(const char * const account_name, const gint val check_expected(value); } +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) { @@ -209,6 +227,12 @@ _mock_accounts_set_priority_xa(const char * const account_name, const gint value check_expected(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) { @@ -216,6 +240,11 @@ _mock_accounts_set_priority_dnd(const char * const account_name, const gint valu 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) @@ -379,6 +408,16 @@ mock_accounts_set_priorities(void) accounts_set_priority_dnd = _mock_accounts_set_priority_dnd; } +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) { 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); } -- cgit 1.4.1-2-gfad0 test, testing POST' href='/gbmor/getwtxt/commit/post_test.go?h=v0.4.10&id=a6c816217f09e4d462949c2631a88439886ed655'>a6c8162 ^
6f93835 ^

a6c8162 ^























6f93835 ^
41398b1 ^
a6c8162 ^






6f93835 ^
a6c8162 ^




a6c8162 ^
6f93835 ^
a6c8162 ^












b957093 ^


41398b1 ^
b957093 ^











41398b1 ^
b957093 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97