예제 #1
0
void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state)
{
    stub_cons_show();
    stub_accounts_set_priorities();
    mock_accounts_get_last_presence();
    mock_presence_update();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "set", "a_account", "online", "10", NULL };

    accounts_account_exists_return(TRUE);

    mock_connection_status(JABBER_CONNECTED);
    mock_connection_account_name("a_account");

    accounts_get_last_presence_return(RESOURCE_ONLINE);

    mock_connection_presence_message("Free to chat");

    presence_update_expect(RESOURCE_ONLINE, "Free to chat", 0);

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #2
0
void cmd_account_rename_shows_usage_when_no_args(void **state)
{
    gchar *args[] = { "rename", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #3
0
void cmd_account_show_message_for_missing_otr_policy(void **state)
{
    gchar *args[] = { "set", "a_account", "otr", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #4
0
void cmd_account_clear_shows_usage_when_one_arg(void **state)
{
    gchar *args[] = { "clear", "a_account", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #5
0
void cmd_account_set_shows_usage_when_two_args(void **state)
{
    gchar *args[] = { "set", "a_account", "a_property", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #6
0
void cmd_account_shows_usage_when_not_connected_and_no_args(void **state)
{
    gchar *args[] = { NULL };

    will_return(connection_get_status, JABBER_DISCONNECTED);

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #7
0
void cmd_account_set_jid_shows_message_for_malformed_jid(void **state)
{
    gchar *args[] = { "set", "a_account", "jid", "@malformed", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Malformed jid: @malformed");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #8
0
void cmd_account_show_message_for_invalid_otr_policy(void **state)
{
    gchar *args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("OTR policy must be one of: manual, opportunistic or always.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #9
0
void cmd_account_set_priority_too_high_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "online", "150", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Value 150 out of range. Must be in -128..127.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #10
0
void cmd_account_set_priority_when_empty_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "online", "", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Could not convert \"\" to a number.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #11
0
void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
{
    gchar *args[] = { "disable", "account_name", NULL };

    expect_any(accounts_disable, name);
    will_return(accounts_disable, FALSE);

    expect_cons_show("No such account: account_name");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #12
0
void cmd_account_disable_disables_account(void **state)
{
    gchar *args[] = { "disable", "account_name", NULL };

    expect_string(accounts_disable, name, "account_name");
    will_return(accounts_disable, TRUE);

    expect_cons_show("Account disabled.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #13
0
void cmd_account_add_adds_account(void **state)
{
    gchar *args[] = { "add", "new_account", NULL };

    expect_string(accounts_add, jid, "new_account");
    expect_value(accounts_add, altdomain, NULL);
    expect_value(accounts_add, port, 0);
    expect_cons_show("Account created.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #14
0
gboolean cmd_identify_finish(gpointer data, gint fd, b_input_condition cond)
{
	char *account_on[] = { "account", "on", NULL };
	irc_t *irc = data;

	if (set_getbool(&irc->b->set, "auto_connect")) {
		cmd_account(irc, account_on);
	}

	b_event_remove(irc->login_source_id);
	irc->login_source_id = -1;
	return FALSE;
}
예제 #15
0
void cmd_account_clear_shows_message_when_invalid_property(void **state)
{
    gchar *args[] = { "clear", "a_account", "badproperty", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Invalid property: badproperty");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #16
0
void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
{
    gchar *args[] = { "show", "account_name", NULL };

    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, NULL);

    expect_cons_show("No such account.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #17
0
void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state)
{
    gchar *args[] = { "clear", "a_account", "a_property", NULL };

    expect_string(accounts_account_exists, account_name, "a_account");
    will_return(accounts_account_exists, FALSE);

    expect_cons_show("Account a_account doesn't exist");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #18
0
void cmd_account_set_last_priority_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "last", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Invalid property: last");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #19
0
void cmd_account_add_adds_account(void **state)
{
    stub_cons_show();
    mock_accounts_add();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "add", "new_account", NULL };

    accounts_add_expect_account_name("new_account");

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #20
0
void cmd_account_show_shows_account_when_exists(void **state)
{
    gchar *args[] = { "show", "account_name", NULL };
    ProfAccount *account = account_new("jabber_org", "*****@*****.**", NULL, NULL,
        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);

    expect_memory(cons_show_account, account, account, sizeof(account));

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #21
0
void cmd_account_disable_disables_account(void **state)
{
    stub_cons_show();
    mock_accounts_disable();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "disable", "account_name", NULL };

    accounts_disable_expect("account_name");

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #22
0
void cmd_account_rename_renames_account(void **state)
{
    stub_cons_show();
    mock_accounts_rename();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "rename", "original_name", "new_name", NULL };

    accounts_rename_expect("original_name", "new_name");

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #23
0
void cmd_account_set_checks_account_exists(void **state)
{
    stub_cons_show();
    mock_accounts_account_exists();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL };

    accounts_account_exists_expect("a_account");

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #24
0
void cmd_account_show_shows_usage_when_no_arg(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    help->usage = "some usage";
    gchar *args[] = { "show", NULL };

    expect_cons_show("Usage: some usage");

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #25
0
void cmd_account_rename_renames_account(void **state)
{
    gchar *args[] = { "rename", "original_name", "new_name", NULL };

    expect_string(accounts_rename, account_name, "original_name");
    expect_string(accounts_rename, new_name, "new_name");
    will_return(accounts_rename, TRUE);

    expect_cons_show("Account renamed.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #26
0
void cmd_account_rename_shows_message_when_not_renamed(void **state)
{
    gchar *args[] = { "rename", "original_name", "new_name", NULL };

    expect_any(accounts_rename, account_name);
    expect_any(accounts_rename, new_name);
    will_return(accounts_rename, FALSE);

    expect_cons_show("Either account original_name doesn't exist, or account new_name already exists.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
예제 #27
0
void cmd_account_set_priority_when_empty_shows_message(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "set", "a_account", "online", "", NULL };

    accounts_account_exists_return(TRUE);

    expect_cons_show("Could not convert \"\" to a number.");

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #28
0
void cmd_account_add_shows_message(void **state)
{
    mock_cons_show();
    stub_accounts_add();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "add", "new_account", NULL };

    expect_cons_show("Account created.");;
    expect_cons_show("");

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #29
0
void cmd_account_set_priority_too_high_shows_message(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "set", "a_account", "online", "150", NULL };

    accounts_account_exists_return(TRUE);

    expect_cons_show("Value 150 out of range. Must be in -128..127.");

    gboolean result = cmd_account(args, *help);
    assert_true(result);

    free(help);
}
예제 #30
0
void cmd_account_shows_account_when_connected_and_no_args(void **state)
{
    ProfAccount *account = account_new("jabber_org", "*****@*****.**", NULL, NULL,
        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    gchar *args[] = { NULL };

    will_return(connection_get_status, JABBER_CONNECTED);
    will_return(session_get_account_name, "account_name");
    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);

    expect_memory(cons_show_account, account, account, sizeof(ProfAccount));

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}