1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Test /otr gen

This commit is contained in:
James Booth 2014-02-16 19:35:40 +00:00
parent e048b3196e
commit 4eac5c0d43
5 changed files with 26 additions and 7 deletions

View File

@ -21,12 +21,6 @@ _mock_otr_libotr_version(void)
return (char *)mock();
}
void
mock_otr_keygen(void)
{
otr_keygen = _mock_otr_keygen;
}
void
mock_otr_libotr_version(void)
{
@ -36,6 +30,7 @@ mock_otr_libotr_version(void)
void
otr_keygen_expect(ProfAccount *account)
{
otr_keygen = _mock_otr_keygen;
expect_memory(_mock_otr_keygen, account, account, sizeof(ProfAccount));
}

View File

@ -3,7 +3,6 @@
#include "config/account.h"
void mock_otr_keygen(void);
void otr_keygen_expect(ProfAccount *account);
void mock_otr_libotr_version(void);

View File

@ -18,6 +18,7 @@
#include "ui/mock_ui.h"
#include "xmpp/mock_xmpp.h"
#include "config/mock_accounts.h"
#include "command/command.h"
#include "command/commands.h"
@ -278,6 +279,28 @@ void cmd_otr_gen_shows_message_when_not_connected(void **state)
free(help);
}
void cmd_otr_gen_generates_key_for_connected_account(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "gen", NULL };
char *account_name = "myaccount";
ProfAccount *account = account_new(account_name, "me@jabber.org", NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL);
stub_cons_show();
mock_connection_status(JABBER_CONNECTED);
mock_accounts_get_account();
mock_connection_account_name(account_name);
accounts_get_account_expect_and_return(account_name, account);
otr_keygen_expect(account);
gboolean result = cmd_otr(args, *help);
assert_true(result);
free(help);
}
#else
void cmd_otr_shows_message_when_otr_unsupported(void **state)
{

View File

@ -16,6 +16,7 @@ void cmd_otr_warn_on_enables_unencrypted_warning(void **state);
void cmd_otr_warn_off_disables_unencrypted_warning(void **state);
void cmd_otr_libver_shows_libotr_version(void **state);
void cmd_otr_gen_shows_message_when_not_connected(void **state);
void cmd_otr_gen_generates_key_for_connected_account(void **state);
#else
void cmd_otr_shows_message_when_otr_unsupported(void **state);
#endif

View File

@ -457,6 +457,7 @@ int main(int argc, char* argv[]) {
close_preferences),
unit_test(cmd_otr_libver_shows_libotr_version),
unit_test(cmd_otr_gen_shows_message_when_not_connected),
unit_test(cmd_otr_gen_generates_key_for_connected_account),
#else
unit_test(cmd_otr_shows_message_when_otr_unsupported),
#endif