void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state) { gchar *args[] = { "log", "on", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_boolean(PREF_CHLOG, FALSE); expect_cons_show("OTR messages will be logged as plaintext."); expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable."); gboolean result = cmd_otr(NULL, CMD_OTR, args); assert_true(result); }
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_disable(NULL, CMD_ACCOUNT, args); assert_true(result); }
void cmd_account_set_status_shows_message_when_invalid_status(void **state) { gchar *args[] = { "set", "a_account", "status", "bad_status", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); expect_cons_show("Invalid status: bad_status"); expect_cons_show(""); gboolean result = cmd_account_set(NULL, CMD_ACCOUNT, args); assert_true(result); }
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_set(NULL, CMD_ACCOUNT, args); assert_true(result); }
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_show(NULL, CMD_ACCOUNT, args); assert_true(result); }
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_clear(NULL, CMD_ACCOUNT, args); assert_true(result); }
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_clear(NULL, CMD_ACCOUNT, args); assert_true(result); }
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_add(NULL, CMD_ACCOUNT, args); assert_true(result); }
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_disable(NULL, CMD_ACCOUNT, args); assert_true(result); }
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_rename(NULL, CMD_ACCOUNT, args); assert_true(result); }
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_rename(NULL, CMD_ACCOUNT, args); assert_true(result); }
void cmd_connect_shows_message_when_port_contains_chars(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "*****@*****.**", "port", "52f66", NULL }; will_return(jabber_get_connection_status, JABBER_DISCONNECTED); expect_cons_show("Could not convert \"52f66\" to a number."); expect_cons_show(""); gboolean result = cmd_connect(NULL, args, *help); assert_true(result); free(help); }
void cmd_connect_shows_message_when_port_65536(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "*****@*****.**", "port", "65536", NULL }; will_return(jabber_get_connection_status, JABBER_DISCONNECTED); expect_cons_show("Value 65536 out of range. Must be in 1..65535."); expect_cons_show(""); gboolean result = cmd_connect(NULL, args, *help); assert_true(result); free(help); }
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); }
void cmd_connect_with_server_and_port_when_provided(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "*****@*****.**", "port", "5432", "server", "aserver", NULL }; will_return(jabber_get_connection_status, JABBER_DISCONNECTED); expect_string(accounts_get_account, name, "*****@*****.**"); will_return(accounts_get_account, NULL); will_return(ui_ask_password, strdup("password")); expect_cons_show("Connecting as [email protected]"); expect_string(jabber_connect_with_details, jid, "*****@*****.**"); expect_string(jabber_connect_with_details, passwd, "password"); expect_string(jabber_connect_with_details, altdomain, "aserver"); expect_value(jabber_connect_with_details, port, 5432); will_return(jabber_connect_with_details, JABBER_CONNECTING); gboolean result = cmd_connect(NULL, args, *help); assert_true(result); free(help); }
void cmd_account_set_status_sets_status_when_last(void **state) { gchar *args[] = { "set", "a_account", "status", "last", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); expect_string(accounts_set_login_presence, account_name, "a_account"); expect_string(accounts_set_login_presence, value, "last"); expect_cons_show("Updated login status for account a_account: last"); expect_cons_show(""); gboolean result = cmd_account_set(NULL, CMD_ACCOUNT, args); assert_true(result); }
void cmd_account_set_nick_sets_nick(void **state) { gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); expect_string(accounts_set_muc_nick, account_name, "a_account"); expect_string(accounts_set_muc_nick, value, "a_nick"); expect_cons_show("Updated muc nick for account a_account: a_nick"); expect_cons_show(""); gboolean result = cmd_account_set(NULL, CMD_ACCOUNT, args); assert_true(result); }
void cmd_account_set_otr_sets_otr(void **state) { gchar *args[] = { "set", "a_account", "otr", "opportunistic", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); expect_string(accounts_set_otr_policy, account_name, "a_account"); expect_string(accounts_set_otr_policy, value, "opportunistic"); expect_cons_show("Updated OTR policy for account a_account: opportunistic"); expect_cons_show(""); gboolean result = cmd_account_set(NULL, CMD_ACCOUNT, args); assert_true(result); }
void cmd_account_set_jid_sets_barejid(void **state) { gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); expect_string(accounts_set_jid, account_name, "a_account"); expect_string(accounts_set_jid, value, "a_local@a_domain"); expect_cons_show("Updated jid for account a_account: a_local@a_domain"); expect_cons_show(""); gboolean result = cmd_account_set(NULL, CMD_ACCOUNT, args); assert_true(result); }
void cmd_connect_fail_message(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "*****@*****.**", NULL }; will_return(jabber_get_connection_status, JABBER_DISCONNECTED); expect_any(accounts_get_account, name); will_return(accounts_get_account, NULL); will_return(ui_ask_password, strdup("password")); expect_cons_show("Connecting as [email protected]"); expect_any(jabber_connect_with_details, jid); expect_any(jabber_connect_with_details, passwd); expect_any(jabber_connect_with_details, altdomain); expect_any(jabber_connect_with_details, port); will_return(jabber_connect_with_details, JABBER_DISCONNECTED); expect_cons_show_error("Connection attempt for [email protected] failed."); gboolean result = cmd_connect(NULL, args, *help); assert_true(result); free(help); }
void cmd_connect_lowercases_argument(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "*****@*****.**", NULL }; will_return(jabber_get_connection_status, JABBER_DISCONNECTED); expect_string(accounts_get_account, name, "*****@*****.**"); will_return(accounts_get_account, NULL); will_return(ui_ask_password, strdup("password")); expect_cons_show("Connecting as [email protected]"); expect_any(jabber_connect_with_details, jid); expect_any(jabber_connect_with_details, passwd); expect_any(jabber_connect_with_details, altdomain); expect_any(jabber_connect_with_details, port); will_return(jabber_connect_with_details, JABBER_CONNECTING); gboolean result = cmd_connect(NULL, args, *help); assert_true(result); free(help); }
void cmd_connect_shows_usage_when_no_port_value(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); help->usage = "some usage"; gchar *args[] = { "*****@*****.**", "port", NULL }; will_return(jabber_get_connection_status, JABBER_DISCONNECTED); expect_cons_show("Usage: some usage"); expect_cons_show(""); gboolean result = cmd_connect(NULL, args, *help); assert_true(result); free(help); }
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_account_rename_shows_message_when_renamed(void **state) { mock_cons_show(); mock_accounts_rename(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "rename", "original_name", "new_name", NULL }; accounts_rename_return(TRUE); expect_cons_show("Account renamed."); expect_cons_show(""); gboolean result = cmd_account(args, *help); assert_true(result); free(help); }
void cmd_account_rename_shows_message_when_not_renamed(void **state) { mock_cons_show(); mock_accounts_rename(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "rename", "original_name", "new_name", NULL }; accounts_rename_return(FALSE); expect_cons_show("Either account original_name doesn't exist, or account new_name already exists."); expect_cons_show(""); gboolean result = cmd_account(args, *help); assert_true(result); free(help); }
void cmd_account_set_shows_message_when_account_doesnt_exist(void **state) { mock_cons_show(); mock_accounts_account_exists(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL }; accounts_account_exists_return(FALSE); expect_cons_show("Account a_account doesn't exist"); expect_cons_show(""); gboolean result = cmd_account(args, *help); assert_true(result); free(help); }
void cmd_account_set_last_priority_shows_message(void **state) { mock_cons_show(); mock_accounts_account_exists(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "set", "a_account", "last", "10", NULL }; accounts_account_exists_return(TRUE); expect_cons_show("Invalid property: last"); expect_cons_show(""); gboolean result = cmd_account(args, *help); assert_true(result); free(help); }
void cmd_account_show_shows_message_when_account_does_not_exist(void **state) { mock_cons_show(); mock_accounts_get_account(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "show", "account_name", NULL }; accounts_get_account_return(NULL); expect_cons_show("No such account."); expect_cons_show(""); gboolean result = cmd_account(args, *help); assert_true(result); free(help); }
void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state) { mock_cons_show(); mock_accounts_disable(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "disable", "account_name", NULL }; accounts_disable_return(FALSE); expect_cons_show("No such account: account_name"); expect_cons_show(""); gboolean result = cmd_account(args, *help); assert_true(result); free(help); }
static void test_with_connection_status(jabber_conn_status_t status) { will_return(connection_get_status, status); expect_cons_show("You are not currently connected."); gboolean result = cmd_join(NULL, CMD_JOIN, NULL); assert_true(result); }