1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

Added cmd_alias tests

This commit is contained in:
James Booth 2014-12-24 20:11:24 +00:00
parent 003002d638
commit 8b4c7e93b8
4 changed files with 11 additions and 15 deletions

View File

@ -67,6 +67,7 @@ tests_sources = \
tests/config/stub_accounts.c \ tests/config/stub_accounts.c \
tests/helpers.c tests/helpers.h \ tests/helpers.c tests/helpers.h \
tests/test_cmd_account.c tests/test_cmd_account.h \ tests/test_cmd_account.c tests/test_cmd_account.h \
tests/test_cmd_alias.c tests/test_cmd_alias.h \
tests/test_autocomplete.c tests/test_autocomplete.h \ tests/test_autocomplete.c tests/test_autocomplete.h \
tests/testsuite.c tests/testsuite.c

View File

@ -7,10 +7,9 @@
#include <glib.h> #include <glib.h>
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
#include "xmpp/mock_xmpp.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "ui/mock_ui.h" #include "ui/stub_ui.h"
#include "config/preferences.h" #include "config/preferences.h"
@ -19,7 +18,6 @@
void cmd_alias_add_shows_usage_when_no_args(void **state) void cmd_alias_add_shows_usage_when_no_args(void **state)
{ {
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage"; help->usage = "some usage";
gchar *args[] = { "add", NULL }; gchar *args[] = { "add", NULL };
@ -34,7 +32,6 @@ void cmd_alias_add_shows_usage_when_no_args(void **state)
void cmd_alias_add_shows_usage_when_no_value(void **state) void cmd_alias_add_shows_usage_when_no_value(void **state)
{ {
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage"; help->usage = "some usage";
gchar *args[] = { "add", "alias", NULL }; gchar *args[] = { "add", "alias", NULL };
@ -49,7 +46,6 @@ void cmd_alias_add_shows_usage_when_no_value(void **state)
void cmd_alias_remove_shows_usage_when_no_args(void **state) void cmd_alias_remove_shows_usage_when_no_args(void **state)
{ {
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage"; help->usage = "some usage";
gchar *args[] = { "remove", NULL }; gchar *args[] = { "remove", NULL };
@ -64,7 +60,6 @@ void cmd_alias_remove_shows_usage_when_no_args(void **state)
void cmd_alias_show_usage_when_invalid_subcmd(void **state) void cmd_alias_show_usage_when_invalid_subcmd(void **state)
{ {
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage"; help->usage = "some usage";
gchar *args[] = { "blah", NULL }; gchar *args[] = { "blah", NULL };
@ -79,7 +74,6 @@ void cmd_alias_show_usage_when_invalid_subcmd(void **state)
void cmd_alias_add_adds_alias(void **state) void cmd_alias_add_adds_alias(void **state)
{ {
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", "hc", "/help commands", NULL }; gchar *args[] = { "add", "hc", "/help commands", NULL };
@ -97,7 +91,6 @@ void cmd_alias_add_adds_alias(void **state)
void cmd_alias_add_shows_message_when_exists(void **state) void cmd_alias_add_shows_message_when_exists(void **state)
{ {
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", "hc", "/help commands", NULL }; gchar *args[] = { "add", "hc", "/help commands", NULL };
@ -115,7 +108,6 @@ void cmd_alias_add_shows_message_when_exists(void **state)
void cmd_alias_remove_removes_alias(void **state) void cmd_alias_remove_removes_alias(void **state)
{ {
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "remove", "hn", NULL }; gchar *args[] = { "remove", "hn", NULL };
@ -135,7 +127,6 @@ void cmd_alias_remove_removes_alias(void **state)
void cmd_alias_remove_shows_message_when_no_alias(void **state) void cmd_alias_remove_shows_message_when_no_alias(void **state)
{ {
mock_cons_show();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "remove", "hn", NULL }; gchar *args[] = { "remove", "hn", NULL };
@ -149,7 +140,6 @@ void cmd_alias_remove_shows_message_when_no_alias(void **state)
void cmd_alias_list_shows_all_aliases(void **state) void cmd_alias_list_shows_all_aliases(void **state)
{ {
mock_cons_show_aliases();
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "list", NULL }; gchar *args[] = { "list", NULL };
@ -160,7 +150,7 @@ void cmd_alias_list_shows_all_aliases(void **state)
prefs_add_alias("vn", "/vercheck off"); prefs_add_alias("vn", "/vercheck off");
// write a custom checker to check the correct list is passed // write a custom checker to check the correct list is passed
expect_cons_show_aliases(); expect_any(cons_show_aliases, aliases);
gboolean result = cmd_alias(args, *help); gboolean result = cmd_alias(args, *help);
assert_true(result); assert_true(result);

View File

@ -390,7 +390,7 @@ int main(int argc, char* argv[]) {
unit_test(handle_message_error_when_recipient_and_no_type), unit_test(handle_message_error_when_recipient_and_no_type),
unit_test(handle_presence_error_when_no_recipient), unit_test(handle_presence_error_when_no_recipient),
unit_test(handle_presence_error_when_from_recipient), unit_test(handle_presence_error_when_from_recipient),
*/
unit_test(cmd_alias_add_shows_usage_when_no_args), unit_test(cmd_alias_add_shows_usage_when_no_args),
unit_test(cmd_alias_add_shows_usage_when_no_value), unit_test(cmd_alias_add_shows_usage_when_no_value),
unit_test(cmd_alias_remove_shows_usage_when_no_args), unit_test(cmd_alias_remove_shows_usage_when_no_args),
@ -410,7 +410,7 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(cmd_alias_list_shows_all_aliases, unit_test_setup_teardown(cmd_alias_list_shows_all_aliases,
load_preferences, load_preferences,
close_preferences), close_preferences),
/*
unit_test_setup_teardown(test_muc_invites_add, muc_before_test, muc_after_test), unit_test_setup_teardown(test_muc_invites_add, muc_before_test, muc_after_test),
unit_test_setup_teardown(test_muc_remove_invite, muc_before_test, muc_after_test), unit_test_setup_teardown(test_muc_remove_invite, muc_before_test, muc_after_test),
unit_test_setup_teardown(test_muc_invites_count_0, muc_before_test, muc_after_test), unit_test_setup_teardown(test_muc_invites_count_0, muc_before_test, muc_after_test),

View File

@ -313,7 +313,12 @@ void cons_show_status(const char * const barejid) {}
void cons_show_info(PContact pcontact) {} void cons_show_info(PContact pcontact) {}
void cons_show_caps(const char * const fulljid, resource_presence_t presence) {} void cons_show_caps(const char * const fulljid, resource_presence_t presence) {}
void cons_show_themes(GSList *themes) {} void cons_show_themes(GSList *themes) {}
void cons_show_aliases(GList *aliases) {}
void cons_show_aliases(GList *aliases)
{
check_expected(aliases);
}
void cons_show_login_success(ProfAccount *account) {} void cons_show_login_success(ProfAccount *account) {}
void cons_show_software_version(const char * const jid, void cons_show_software_version(const char * const jid,
const char * const presence, const char * const name, const char * const presence, const char * const name,