mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Test /otr gen
This commit is contained in:
parent
e048b3196e
commit
4eac5c0d43
@ -21,12 +21,6 @@ _mock_otr_libotr_version(void)
|
|||||||
return (char *)mock();
|
return (char *)mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
mock_otr_keygen(void)
|
|
||||||
{
|
|
||||||
otr_keygen = _mock_otr_keygen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mock_otr_libotr_version(void)
|
mock_otr_libotr_version(void)
|
||||||
{
|
{
|
||||||
@ -36,6 +30,7 @@ mock_otr_libotr_version(void)
|
|||||||
void
|
void
|
||||||
otr_keygen_expect(ProfAccount *account)
|
otr_keygen_expect(ProfAccount *account)
|
||||||
{
|
{
|
||||||
|
otr_keygen = _mock_otr_keygen;
|
||||||
expect_memory(_mock_otr_keygen, account, account, sizeof(ProfAccount));
|
expect_memory(_mock_otr_keygen, account, account, sizeof(ProfAccount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "config/account.h"
|
#include "config/account.h"
|
||||||
|
|
||||||
void mock_otr_keygen(void);
|
|
||||||
void otr_keygen_expect(ProfAccount *account);
|
void otr_keygen_expect(ProfAccount *account);
|
||||||
|
|
||||||
void mock_otr_libotr_version(void);
|
void mock_otr_libotr_version(void);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "ui/mock_ui.h"
|
#include "ui/mock_ui.h"
|
||||||
#include "xmpp/mock_xmpp.h"
|
#include "xmpp/mock_xmpp.h"
|
||||||
|
#include "config/mock_accounts.h"
|
||||||
|
|
||||||
#include "command/command.h"
|
#include "command/command.h"
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
@ -278,6 +279,28 @@ void cmd_otr_gen_shows_message_when_not_connected(void **state)
|
|||||||
|
|
||||||
free(help);
|
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
|
#else
|
||||||
void cmd_otr_shows_message_when_otr_unsupported(void **state)
|
void cmd_otr_shows_message_when_otr_unsupported(void **state)
|
||||||
{
|
{
|
||||||
|
@ -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_warn_off_disables_unencrypted_warning(void **state);
|
||||||
void cmd_otr_libver_shows_libotr_version(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_shows_message_when_not_connected(void **state);
|
||||||
|
void cmd_otr_gen_generates_key_for_connected_account(void **state);
|
||||||
#else
|
#else
|
||||||
void cmd_otr_shows_message_when_otr_unsupported(void **state);
|
void cmd_otr_shows_message_when_otr_unsupported(void **state);
|
||||||
#endif
|
#endif
|
||||||
|
@ -457,6 +457,7 @@ int main(int argc, char* argv[]) {
|
|||||||
close_preferences),
|
close_preferences),
|
||||||
unit_test(cmd_otr_libver_shows_libotr_version),
|
unit_test(cmd_otr_libver_shows_libotr_version),
|
||||||
unit_test(cmd_otr_gen_shows_message_when_not_connected),
|
unit_test(cmd_otr_gen_shows_message_when_not_connected),
|
||||||
|
unit_test(cmd_otr_gen_generates_key_for_connected_account),
|
||||||
#else
|
#else
|
||||||
unit_test(cmd_otr_shows_message_when_otr_unsupported),
|
unit_test(cmd_otr_shows_message_when_otr_unsupported),
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user