mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added cmd_bookmark tests
This commit is contained in:
parent
23842e5254
commit
652e99fdd8
@ -79,6 +79,7 @@ test_sources = \
|
||||
tests/test_cmd_sub.c \
|
||||
tests/test_cmd_alias.c \
|
||||
tests/test_cmd_statuses.c \
|
||||
tests/test_cmd_bookmark.c \
|
||||
tests/test_history.c \
|
||||
tests/test_jid.c \
|
||||
tests/test_parser.c \
|
||||
|
@ -1713,6 +1713,11 @@ cmd_bookmark(gchar **args, struct cmd_help_t help)
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
gchar *cmd = args[0];
|
||||
|
||||
if (cmd == NULL) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currenlty connect.");
|
||||
return TRUE;
|
||||
|
30
tests/test_cmd_bookmark.c
Normal file
30
tests/test_cmd_bookmark.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/mock_xmpp.h"
|
||||
|
||||
#include "command/commands.h"
|
||||
|
||||
#include "ui/mock_ui.h"
|
||||
|
||||
void cmd_bookmark_shows_usage_when_no_args(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { NULL };
|
||||
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
expect_cons_show("Usage: some usage");
|
||||
|
||||
gboolean result = cmd_bookmark(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
1
tests/test_cmd_bookmark.h
Normal file
1
tests/test_cmd_bookmark.h
Normal file
@ -0,0 +1 @@
|
||||
void cmd_bookmark_shows_usage_when_no_args(void **state);
|
@ -23,6 +23,7 @@
|
||||
#include "test_preferences.h"
|
||||
#include "test_server_events.h"
|
||||
#include "test_cmd_alias.h"
|
||||
#include "test_cmd_bookmark.h"
|
||||
#include "test_muc.h"
|
||||
|
||||
#define PROF_RUN_TESTS(name) fprintf(stderr, "\n-> Running %s\n", #name); \
|
||||
@ -437,6 +438,11 @@ int main(int argc, char* argv[]) {
|
||||
unit_test_setup_teardown(test_muc_room_is_active, muc_before_test, muc_after_test),
|
||||
};
|
||||
|
||||
const UnitTest cmd_bookmark_tests[] = {
|
||||
unit_test(cmd_bookmark_shows_usage_when_no_args),
|
||||
};
|
||||
|
||||
|
||||
int bak, bak2, new;
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
@ -467,6 +473,7 @@ int main(int argc, char* argv[]) {
|
||||
PROF_RUN_TESTS(cmd_alias_tests);
|
||||
PROF_RUN_TESTS(server_events_tests);
|
||||
PROF_RUN_TESTS(muc_tests);
|
||||
PROF_RUN_TESTS(cmd_bookmark_tests);
|
||||
|
||||
fflush(stdout);
|
||||
dup2(bak, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user