Test "/account list"

This commit is contained in:
James Booth
2013-12-15 23:07:53 +00:00
parent 683da12c3a
commit 6f060b583e
4 changed files with 32 additions and 2 deletions

View File

@@ -7,6 +7,7 @@
#include <glib.h>
#include "xmpp/xmpp.h"
#include "ui/ui.h"
#include "command/commands.h"
void cmd_account_shows_usage_when_not_connected_and_no_args(void **state)
@@ -32,7 +33,7 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state)
gchar *args[] = { NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED);
will_return(jabber_get_account_name, "account_name");
expect_string(accounts_get_account, name, "account_name");
@@ -45,5 +46,27 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state)
gboolean result = cmd_account(args, *help);
assert_true(result);
free(help);
free(account);
}
void cmd_account_list_shows_accounts(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "list" };
gchar **accounts = malloc(sizeof(gchar *) * 4);
accounts[0] = strdup("account1");
accounts[1] = strdup("account2");
accounts[2] = strdup("account3");
accounts[3] = NULL;
will_return(accounts_get_list, accounts);
expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts));
gboolean result = cmd_account(args, *help);
assert_true(result);
free(help);
}