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

Added cmd_connect tests for invalid properties

This commit is contained in:
James Booth 2014-01-18 22:55:15 +00:00
parent 91d4097df9
commit bd221f6f30
3 changed files with 42 additions and 0 deletions

View File

@ -238,6 +238,44 @@ void cmd_connect_shows_usage_when_port_provided_twice(void **state)
free(help);
}
void cmd_connect_shows_usage_when_invalid_first_property(void **state)
{
stub_ui_ask_password();
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "wrong", "server", 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_shows_usage_when_invalid_second_property(void **state)
{
stub_ui_ask_password();
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "server", "aserver", "wrong", "1234", 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)
{
mock_cons_show();

View File

@ -23,3 +23,5 @@ void cmd_connect_with_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);
void cmd_connect_shows_usage_when_port_provided_twice(void **state);
void cmd_connect_shows_usage_when_invalid_first_property(void **state);
void cmd_connect_shows_usage_when_invalid_second_property(void **state);

View File

@ -192,6 +192,8 @@ int main(int argc, char* argv[]) {
unit_test(cmd_connect_with_server_and_port_when_provided),
unit_test(cmd_connect_shows_usage_when_server_provided_twice),
unit_test(cmd_connect_shows_usage_when_port_provided_twice),
unit_test(cmd_connect_shows_usage_when_invalid_first_property),
unit_test(cmd_connect_shows_usage_when_invalid_second_property),
unit_test(cmd_rooms_shows_message_when_disconnected),
unit_test(cmd_rooms_shows_message_when_disconnecting),