Add nickname support for /roster remove

Add support of name/nickname instead of only JID for `/roster remove` command.

Add tests for it as well.
This commit is contained in:
John Hernandez
2023-04-13 15:23:45 +02:00
parent 766dc76e33
commit 5b8b9074a2
9 changed files with 65 additions and 7 deletions

View File

@@ -114,12 +114,34 @@ cmd_roster_remove_sends_roster_remove_request(void** state)
char* jid = "bob@server.org";
gchar* args[] = { "remove", jid, NULL };
roster_create();
roster_add("bob@server.org", "bob", NULL, "both", FALSE);
will_return(connection_get_status, JABBER_CONNECTED);
expect_string(roster_send_remove, barejid, jid);
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result);
roster_destroy();
}
void
cmd_roster_remove_nickname_sends_roster_remove_request(void** state)
{
char* jid = "bob@server.org";
gchar* args[] = { "remove", "bob", NULL };
roster_create();
roster_add("bob@server.org", "bob", NULL, "both", FALSE);
will_return(connection_get_status, JABBER_CONNECTED);
expect_string(roster_send_remove, barejid, jid);
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result);
roster_destroy();
}
void

View File

@@ -7,6 +7,7 @@ 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);
void cmd_roster_remove_nickname_sends_roster_remove_request(void** state);
void cmd_roster_nick_shows_message_when_no_jid(void** state);
void cmd_roster_nick_shows_message_when_no_nick(void** state);
void cmd_roster_nick_shows_message_when_no_contact_exists(void** state);

View File

@@ -584,6 +584,7 @@ main(int argc, char* argv[])
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),
unit_test(cmd_roster_remove_nickname_sends_roster_remove_request),
unit_test(cmd_roster_nick_shows_message_when_no_jid),
unit_test(cmd_roster_nick_shows_message_when_no_nick),
unit_test(cmd_roster_nick_shows_message_when_no_contact_exists),