Added /roster clearnick command
This commit is contained in:
@@ -118,7 +118,7 @@ void cmd_roster_remove_shows_message_when_no_jid(void **state)
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_roster_remove_sends_roster_remove_request(void)
|
||||
void cmd_roster_remove_sends_roster_remove_request(void **state)
|
||||
{
|
||||
char *jid = "bob@server.org";
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
@@ -133,3 +133,142 @@ void cmd_roster_remove_sends_roster_remove_request(void)
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_roster_nick_shows_message_when_no_jid(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "nick", 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_nick_shows_message_when_no_nick(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "nick", "bob@server.org", 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_nick_shows_message_when_no_contact_exists(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "nick", "bob@server.org", "bobster", NULL };
|
||||
|
||||
roster_init();
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
expect_cons_show("Contact not found in roster: bob@server.org");
|
||||
|
||||
gboolean result = cmd_roster(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
roster_free();
|
||||
}
|
||||
|
||||
void cmd_roster_nick_sends_name_change_request(void **state)
|
||||
{
|
||||
char *jid = "bob@server.org";
|
||||
char *nick = "bobster";
|
||||
mock_cons_show();
|
||||
mock_roster_send_name_change();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "nick", jid, nick, NULL };
|
||||
|
||||
roster_init();
|
||||
GSList *groups = NULL;
|
||||
groups = g_slist_append(groups, "group1");
|
||||
roster_add(jid, "bob", groups, "both", FALSE);
|
||||
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
roster_send_name_change_expect(jid, nick, groups);
|
||||
expect_cons_show("Nickname for bob@server.org set to: bobster.");
|
||||
|
||||
gboolean result = cmd_roster(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
PContact contact = roster_get_contact(jid);
|
||||
assert_string_equal(p_contact_name(contact), nick);
|
||||
|
||||
free(help);
|
||||
roster_free();
|
||||
}
|
||||
|
||||
void cmd_roster_clearnick_shows_message_when_no_jid(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "clearnick", 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_clearnick_shows_message_when_no_contact_exists(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "clearnick", "bob@server.org", NULL };
|
||||
|
||||
roster_init();
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
expect_cons_show("Contact not found in roster: bob@server.org");
|
||||
|
||||
gboolean result = cmd_roster(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
roster_free();
|
||||
}
|
||||
|
||||
void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state)
|
||||
{
|
||||
char *jid = "bob@server.org";
|
||||
mock_cons_show();
|
||||
mock_roster_send_name_change();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "clearnick", jid, NULL };
|
||||
|
||||
roster_init();
|
||||
GSList *groups = NULL;
|
||||
groups = g_slist_append(groups, "group1");
|
||||
roster_add(jid, "bob", groups, "both", FALSE);
|
||||
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
roster_send_name_change_expect(jid, NULL, groups);
|
||||
expect_cons_show("Nickname for bob@server.org removed.");
|
||||
|
||||
gboolean result = cmd_roster(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
PContact contact = roster_get_contact(jid);
|
||||
assert_null(p_contact_name(contact));
|
||||
|
||||
free(help);
|
||||
roster_free();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user