mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Added test to show usage when no room supplied to /join
This commit is contained in:
parent
f3fe1d34d2
commit
2d54c565ce
@ -1583,6 +1583,12 @@ cmd_join(gchar **args, struct cmd_help_t help)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (args[0] == NULL) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
cons_show("");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Jid *room_arg = jid_create(args[0]);
|
||||
if (room_arg == NULL) {
|
||||
cons_show_error("Specified room has incorrect format");
|
||||
@ -1594,8 +1600,10 @@ cmd_join(gchar **args, struct cmd_help_t help)
|
||||
char *nick = NULL;
|
||||
char *passwd = NULL;
|
||||
GString *room_str = g_string_new("");
|
||||
Jid *my_jid = jid_create(jabber_get_fulljid());
|
||||
ProfAccount *account = accounts_get_account(jabber_get_account_name());
|
||||
const char *full_jid = jabber_get_fulljid();
|
||||
Jid *my_jid = jid_create(full_jid);
|
||||
char *account_name = jabber_get_account_name();
|
||||
ProfAccount *account = accounts_get_account(account_name);
|
||||
|
||||
// full room jid supplied (room@server)
|
||||
if (room_arg->localpart != NULL) {
|
||||
|
@ -48,6 +48,25 @@ void cmd_join_shows_message_when_undefined(void **state)
|
||||
{
|
||||
test_with_connection_status(JABBER_UNDEFINED);
|
||||
}
|
||||
|
||||
void cmd_join_shows_usage_when_no_args(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { NULL };
|
||||
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
|
||||
expect_cons_show("Usage: some usage");
|
||||
expect_cons_show("");
|
||||
|
||||
gboolean result = cmd_join(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
/*
|
||||
void cmd_connect_shows_usage_when_no_server_value(void **state)
|
||||
{
|
||||
|
@ -2,3 +2,4 @@ void cmd_join_shows_message_when_disconnecting(void **state);
|
||||
void cmd_join_shows_message_when_connecting(void **state);
|
||||
void cmd_join_shows_message_when_disconnected(void **state);
|
||||
void cmd_join_shows_message_when_undefined(void **state);
|
||||
void cmd_join_shows_usage_when_no_args(void **state);
|
||||
|
@ -491,6 +491,7 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_join_shows_message_when_connecting),
|
||||
unit_test(cmd_join_shows_message_when_disconnected),
|
||||
unit_test(cmd_join_shows_message_when_undefined),
|
||||
unit_test(cmd_join_shows_usage_when_no_args),
|
||||
};
|
||||
|
||||
return run_tests(all_tests);
|
||||
|
Loading…
Reference in New Issue
Block a user