1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added /roster remove tests

This commit is contained in:
James Booth 2014-03-16 16:00:10 +00:00
parent a578419d55
commit bcafba2de6
5 changed files with 59 additions and 2 deletions

View File

@ -69,7 +69,7 @@ void cmd_roster_shows_roster_when_no_args(void **state)
roster_free();
}
void cmd_roster_add_shows_message_when_no_jid(void)
void cmd_roster_add_shows_message_when_no_jid(void **state)
{
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp));
@ -85,7 +85,7 @@ void cmd_roster_add_shows_message_when_no_jid(void)
free(help);
}
void cmd_roster_add_sends_roster_add_request(void)
void cmd_roster_add_sends_roster_add_request(void **state)
{
char *jid = "bob@server.org";
char *nick = "bob";
@ -101,3 +101,35 @@ void cmd_roster_add_sends_roster_add_request(void)
free(help);
}
void cmd_roster_remove_shows_message_when_no_jid(void **state)
{
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "remove", NULL };
mock_connection_status(JABBER_CONNECTED);
expect_cons_show("Usage: some usage");
gboolean result = cmd_roster(args, *help);
assert_true(result);
free(help);
}
void cmd_roster_remove_sends_roster_remove_request(void)
{
char *jid = "bob@server.org";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "remove", jid, NULL };
mock_roster_send_remove();
mock_connection_status(JABBER_CONNECTED);
roster_send_remove_expect(jid);
gboolean result = cmd_roster(args, *help);
assert_true(result);
free(help);
}

View File

@ -5,3 +5,5 @@ void cmd_roster_shows_message_when_undefined(void **state);
void cmd_roster_shows_roster_when_no_args(void **state);
void cmd_roster_add_shows_message_when_no_jid(void **state);
void cmd_roster_add_sends_roster_add_request(void **state);
void cmd_roster_remove_shows_message_when_no_jid(void **state);
void cmd_roster_remove_sends_roster_remove_request(void **state);

View File

@ -509,6 +509,8 @@ int main(int argc, char* argv[]) {
unit_test(cmd_roster_shows_roster_when_no_args),
unit_test(cmd_roster_add_shows_message_when_no_jid),
unit_test(cmd_roster_add_sends_roster_add_request),
unit_test(cmd_roster_remove_shows_message_when_no_jid),
unit_test(cmd_roster_remove_sends_roster_remove_request),
};
return run_tests(all_tests);

View File

@ -103,6 +103,12 @@ _mock_roster_send_add_new(const char *const barejid, const char * const name)
check_expected(name);
}
static void
_mock_roster_send_remove(const char * const barejid)
{
check_expected(barejid);
}
void
mock_jabber_connect_with_details(void)
{
@ -152,6 +158,12 @@ mock_roster_send_add_new(void)
roster_send_add_new = _mock_roster_send_add_new;
}
void
mock_roster_send_remove(void)
{
roster_send_remove = _mock_roster_send_remove;
}
void
bookmark_get_list_returns(GList *bookmarks)
{
@ -280,3 +292,9 @@ roster_send_add_new_expect(char *jid, char *nick)
expect_string(_mock_roster_send_add_new, barejid, jid);
expect_string(_mock_roster_send_add_new, name, nick);
}
void
roster_send_remove_expect(char *jid)
{
expect_string(_mock_roster_send_remove, barejid, jid);
}

View File

@ -39,4 +39,7 @@ void presence_join_room_expect(char *room, char *nick, char *passwd);
void mock_roster_send_add_new(void);
void roster_send_add_new_expect(char *jid, char *nick);
void mock_roster_send_remove(void);
void roster_send_remove_expect(char *jid);
#endif