mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Test account free'd after connect
This commit is contained in:
parent
5ec2d3cf7c
commit
6d75ebb8e9
@ -78,6 +78,7 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
||||
}
|
||||
cons_show("Connecting with account %s as %s", account->name, jid);
|
||||
conn_status = jabber_connect_with_account(account);
|
||||
accounts_free_account(account);
|
||||
} else {
|
||||
char *passwd = ui_ask_password();
|
||||
jid = strdup(lower);
|
||||
@ -92,7 +93,6 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
||||
log_debug("Connection attempt for %s failed", jid);
|
||||
}
|
||||
|
||||
accounts_free_account(account);
|
||||
free(jid);
|
||||
|
||||
result = TRUE;
|
||||
|
@ -54,7 +54,10 @@ ProfAccount* accounts_get_account(const char * const name)
|
||||
return (ProfAccount *)mock();
|
||||
}
|
||||
|
||||
void accounts_free_account(ProfAccount *account) {}
|
||||
void accounts_free_account(ProfAccount *account)
|
||||
{
|
||||
check_expected(account);
|
||||
}
|
||||
|
||||
gboolean accounts_enable(const char * const name)
|
||||
{
|
||||
|
@ -166,6 +166,8 @@ void cmd_connect_asks_password_when_not_in_account(void **state)
|
||||
expect_any(jabber_connect_with_account, account);
|
||||
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
||||
|
||||
expect_any(accounts_free_account, account);
|
||||
|
||||
gboolean result = cmd_connect(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
@ -193,6 +195,8 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state)
|
||||
expect_any(jabber_connect_with_account, account);
|
||||
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
||||
|
||||
expect_any(accounts_free_account, account);
|
||||
|
||||
gboolean result = cmd_connect(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
@ -220,10 +224,38 @@ void cmd_connect_connects_with_account(void **state)
|
||||
expect_memory(jabber_connect_with_account, account, account, sizeof(ProfAccount));
|
||||
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
||||
|
||||
expect_any(accounts_free_account, account);
|
||||
|
||||
gboolean result = cmd_connect(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
free(account);
|
||||
}
|
||||
|
||||
void cmd_connect_frees_account_after_connecting(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "jabber_org", NULL };
|
||||
ProfAccount *account = malloc(sizeof(ProfAccount));
|
||||
|
||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||
|
||||
expect_any(accounts_get_account, name);
|
||||
will_return(accounts_get_account, account);
|
||||
|
||||
will_return(accounts_create_full_jid, strdup("user@jabber.org/laptop"));
|
||||
|
||||
expect_any(cons_show, output);
|
||||
|
||||
expect_any(jabber_connect_with_account, account);
|
||||
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
||||
|
||||
expect_memory(accounts_free_account, account, account, sizeof(ProfAccount));
|
||||
|
||||
gboolean result = cmd_connect(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
free(account);
|
||||
|
||||
}
|
||||
|
@ -9,3 +9,4 @@ void cmd_connect_lowercases_argument(void **state);
|
||||
void cmd_connect_asks_password_when_not_in_account(void **state);
|
||||
void cmd_connect_shows_message_when_connecting_with_account(void **state);
|
||||
void cmd_connect_connects_with_account(void **state);
|
||||
void cmd_connect_frees_account_after_connecting(void **state);
|
||||
|
@ -25,6 +25,7 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_connect_asks_password_when_not_in_account),
|
||||
unit_test(cmd_connect_shows_message_when_connecting_with_account),
|
||||
unit_test(cmd_connect_connects_with_account),
|
||||
unit_test(cmd_connect_frees_account_after_connecting),
|
||||
|
||||
unit_test(cmd_rooms_shows_message_when_disconnected),
|
||||
unit_test(cmd_rooms_shows_message_when_disconnecting),
|
||||
|
Loading…
Reference in New Issue
Block a user