mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added cmd_connect test for repeated server property
This commit is contained in:
parent
0ee6c7a6f1
commit
21f0bd04a8
@ -79,7 +79,7 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
|||||||
// parse options
|
// parse options
|
||||||
char *altdomain = NULL;
|
char *altdomain = NULL;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
gboolean altdomain_set = FALSE;
|
gboolean server_set = FALSE;
|
||||||
gboolean port_set = FALSE;
|
gboolean port_set = FALSE;
|
||||||
if (opt1 != NULL) {
|
if (opt1 != NULL) {
|
||||||
if (opt1val == NULL) {
|
if (opt1val == NULL) {
|
||||||
@ -89,7 +89,7 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
if (strcmp(opt1, "server") == 0) {
|
if (strcmp(opt1, "server") == 0) {
|
||||||
altdomain = opt1val;
|
altdomain = opt1val;
|
||||||
altdomain_set = TRUE;
|
server_set = TRUE;
|
||||||
} else if (strcmp(opt1, "port") == 0) {
|
} else if (strcmp(opt1, "port") == 0) {
|
||||||
if (_strtoi(opt1val, &port, 1, 65535) != 0) {
|
if (_strtoi(opt1val, &port, 1, 65535) != 0) {
|
||||||
port = 0;
|
port = 0;
|
||||||
@ -105,18 +105,23 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opt2 != NULL) {
|
if (opt2 != NULL) {
|
||||||
|
if (server_set && strcmp("server", opt2) == 0) {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
cons_show("");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
if (opt2val == NULL) {
|
if (opt2val == NULL) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
cons_show("");
|
cons_show("");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (strcmp(opt2, "server") == 0) {
|
if (strcmp(opt2, "server") == 0) {
|
||||||
if (altdomain_set) {
|
if (server_set) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
altdomain = opt2val;
|
altdomain = opt2val;
|
||||||
altdomain_set = TRUE;
|
server_set = TRUE;
|
||||||
} else if (strcmp(opt2, "port") == 0) {
|
} else if (strcmp(opt2, "port") == 0) {
|
||||||
if (port_set) {
|
if (port_set) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
|
@ -200,6 +200,25 @@ void cmd_connect_shows_message_when_port_contains_chars(void **state)
|
|||||||
free(help);
|
free(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_usage_when_server_provided_twice(void **state)
|
||||||
|
{
|
||||||
|
stub_ui_ask_password();
|
||||||
|
mock_cons_show();
|
||||||
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
|
help->usage = "some usage";
|
||||||
|
gchar *args[] = { "user@server.org", "server", "server1", "server", "server2", NULL };
|
||||||
|
|
||||||
|
mock_connection_status(JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_cons_show("Usage: some usage");
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(args, *help);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
|
free(help);
|
||||||
|
}
|
||||||
|
|
||||||
void cmd_connect_when_no_account(void **state)
|
void cmd_connect_when_no_account(void **state)
|
||||||
{
|
{
|
||||||
mock_cons_show();
|
mock_cons_show();
|
||||||
|
@ -21,3 +21,4 @@ void cmd_connect_shows_message_when_port_contains_chars(void **state);
|
|||||||
void cmd_connect_with_server_when_provided(void **state);
|
void cmd_connect_with_server_when_provided(void **state);
|
||||||
void cmd_connect_with_port_when_provided(void **state);
|
void cmd_connect_with_port_when_provided(void **state);
|
||||||
void cmd_connect_with_server_and_port_when_provided(void **state);
|
void cmd_connect_with_server_and_port_when_provided(void **state);
|
||||||
|
void cmd_connect_shows_usage_when_server_provided_twice(void **state);
|
||||||
|
@ -190,6 +190,7 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test(cmd_connect_with_server_when_provided),
|
unit_test(cmd_connect_with_server_when_provided),
|
||||||
unit_test(cmd_connect_with_port_when_provided),
|
unit_test(cmd_connect_with_port_when_provided),
|
||||||
unit_test(cmd_connect_with_server_and_port_when_provided),
|
unit_test(cmd_connect_with_server_and_port_when_provided),
|
||||||
|
unit_test(cmd_connect_shows_usage_when_server_provided_twice),
|
||||||
|
|
||||||
unit_test(cmd_rooms_shows_message_when_disconnected),
|
unit_test(cmd_rooms_shows_message_when_disconnected),
|
||||||
unit_test(cmd_rooms_shows_message_when_disconnecting),
|
unit_test(cmd_rooms_shows_message_when_disconnecting),
|
||||||
|
Loading…
Reference in New Issue
Block a user