mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Fixed cmd_bookmark message when not connected
This commit is contained in:
parent
652e99fdd8
commit
614ae232ef
@ -1711,15 +1711,15 @@ gboolean
|
||||
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);
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currently connected.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currenlty connect.");
|
||||
gchar *cmd = args[0];
|
||||
if (cmd == NULL) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,45 @@
|
||||
|
||||
#include "ui/mock_ui.h"
|
||||
|
||||
static void test_with_connection_status(jabber_conn_status_t status)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
|
||||
mock_connection_status(status);
|
||||
expect_cons_show("You are not currently connected.");
|
||||
|
||||
gboolean result = cmd_bookmark(NULL, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_bookmark_shows_message_when_disconnected(void **state)
|
||||
{
|
||||
test_with_connection_status(JABBER_DISCONNECTED);
|
||||
}
|
||||
|
||||
void cmd_bookmark_shows_message_when_disconnecting(void **state)
|
||||
{
|
||||
test_with_connection_status(JABBER_DISCONNECTING);
|
||||
}
|
||||
|
||||
void cmd_bookmark_shows_message_when_connecting(void **state)
|
||||
{
|
||||
test_with_connection_status(JABBER_CONNECTING);
|
||||
}
|
||||
|
||||
void cmd_bookmark_shows_message_when_started(void **state)
|
||||
{
|
||||
test_with_connection_status(JABBER_STARTED);
|
||||
}
|
||||
|
||||
void cmd_bookmark_shows_message_when_undefined(void **state)
|
||||
{
|
||||
test_with_connection_status(JABBER_UNDEFINED);
|
||||
}
|
||||
|
||||
void cmd_bookmark_shows_usage_when_no_args(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
|
@ -1 +1,6 @@
|
||||
void cmd_bookmark_shows_message_when_disconnected(void **state);
|
||||
void cmd_bookmark_shows_message_when_disconnecting(void **state);
|
||||
void cmd_bookmark_shows_message_when_connecting(void **state);
|
||||
void cmd_bookmark_shows_message_when_started(void **state);
|
||||
void cmd_bookmark_shows_message_when_undefined(void **state);
|
||||
void cmd_bookmark_shows_usage_when_no_args(void **state);
|
||||
|
@ -439,6 +439,11 @@ int main(int argc, char* argv[]) {
|
||||
};
|
||||
|
||||
const UnitTest cmd_bookmark_tests[] = {
|
||||
unit_test(cmd_bookmark_shows_message_when_disconnected),
|
||||
unit_test(cmd_bookmark_shows_message_when_disconnecting),
|
||||
unit_test(cmd_bookmark_shows_message_when_connecting),
|
||||
unit_test(cmd_bookmark_shows_message_when_started),
|
||||
unit_test(cmd_bookmark_shows_message_when_undefined),
|
||||
unit_test(cmd_bookmark_shows_usage_when_no_args),
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user