Fix tests, move glob creation

This commit is contained in:
James Booth
2018-01-27 23:51:03 +00:00
parent 2e414797a4
commit e571ccd8ea
10 changed files with 67 additions and 43 deletions

View File

@@ -14,8 +14,8 @@
void
rooms_query(void **state)
{
stbbr_for_id("confreq",
"<iq id='confreq' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
stbbr_for_id("prof_confreq_4",
"<iq id='prof_confreq_4' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#items'>"
"<item jid='chatroom@conference.localhost' name='A chat room'/>"
"<item jid='hangout@conference.localhost' name='Another chat room'/>"
@@ -25,13 +25,13 @@ rooms_query(void **state)
prof_connect();
prof_input("/rooms conference.localhost");
prof_input("/rooms service conference.localhost");
assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)"));
assert_true(prof_output_exact("hangout@conference.localhost, (Another chat room)"));
assert_true(prof_output_exact("chatroom@conference.localhost (A chat room)"));
assert_true(prof_output_exact("hangout@conference.localhost (Another chat room)"));
assert_true(stbbr_last_received(
"<iq id='confreq' to='conference.localhost' type='get'>"
"<iq id='prof_confreq_4' to='conference.localhost' type='get'>"
"<query xmlns='http://jabber.org/protocol/disco#items'/>"
"</iq>"
));

View File

@@ -54,18 +54,39 @@ void cmd_rooms_uses_account_default_when_no_arg(void **state)
will_return(accounts_get_account, account);
expect_string(iq_room_list_request, conferencejid, "default_conf_server");
expect_any(iq_room_list_request, filter);
gboolean result = cmd_rooms(NULL, CMD_ROOMS, args);
assert_true(result);
}
void cmd_rooms_arg_used_when_passed(void **state)
void cmd_rooms_service_arg_used_when_passed(void **state)
{
gchar *args[] = { "conf_server_arg" };
gchar *args[] = { "service", "conf_server_arg", NULL };
will_return(connection_get_status, JABBER_CONNECTED);
expect_string(iq_room_list_request, conferencejid, "conf_server_arg");
expect_any(iq_room_list_request, filter);
gboolean result = cmd_rooms(NULL, CMD_ROOMS, args);
assert_true(result);
}
void cmd_rooms_filter_arg_used_when_passed(void **state)
{
gchar *args[] = { "filter", "text", NULL };
ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL,
0, 0, 0, 0, 0, strdup("default_conf_server"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_CONNECTED);
will_return(session_get_account_name, "account_name");
expect_any(accounts_get_account, name);
will_return(accounts_get_account, account);
expect_any(iq_room_list_request, conferencejid);
expect_string(iq_room_list_request, filter, "text");
gboolean result = cmd_rooms(NULL, CMD_ROOMS, args);
assert_true(result);

View File

@@ -3,4 +3,5 @@ void cmd_rooms_shows_message_when_disconnecting(void **state);
void cmd_rooms_shows_message_when_connecting(void **state);
void cmd_rooms_shows_message_when_undefined(void **state);
void cmd_rooms_uses_account_default_when_no_arg(void **state);
void cmd_rooms_arg_used_when_passed(void **state);
void cmd_rooms_service_arg_used_when_passed(void **state);
void cmd_rooms_filter_arg_used_when_passed(void **state);

View File

@@ -313,7 +313,8 @@ int main(int argc, char* argv[]) {
unit_test(cmd_rooms_shows_message_when_disconnecting),
unit_test(cmd_rooms_shows_message_when_connecting),
unit_test(cmd_rooms_uses_account_default_when_no_arg),
unit_test(cmd_rooms_arg_used_when_passed),
unit_test(cmd_rooms_service_arg_used_when_passed),
unit_test(cmd_rooms_filter_arg_used_when_passed),
unit_test(cmd_account_shows_usage_when_not_connected_and_no_args),
unit_test(cmd_account_shows_account_when_connected_and_no_args),

View File

@@ -172,9 +172,10 @@ void iq_disable_carbons() {};
void iq_enable_carbons() {};
void iq_send_software_version(const char * const fulljid) {}
void iq_room_list_request(gchar *conferencejid)
void iq_room_list_request(gchar *conferencejid, gchar *filter)
{
check_expected(conferencejid);
check_expected(filter);
}
void iq_disco_info_request(gchar *jid) {}