about summary refs log tree commit diff stats
path: root/.github/ISSUE_TEMPLATE/bug-report.md
blob: 5270161b420db152288281fc9f1a6c95e45a0e6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
name: Bug Report
about: Help improve getwtxt by informing us of issues
title: "[BUG]"
labels: bug
assignees: gbmor

---

**Basic Information**
Please include at the very least:
* `go version`
* `go env`
* `getwtxt` version (numeric tag or commit ID)
* The OS you're using

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Exact steps to reproduce the behavior

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.
bbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#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 "ui/ui.h"
#include "ui/stub_ui.h"

#include "config/preferences.h"

#include "command/cmd_defs.h"
#include "command/cmd_funcs.h"
#include "command/cmd_ac.h"

#define CMD_ALIAS "/alias"

void cmd_alias_add_shows_usage_when_no_args(void **state)
{
    gchar *args[] = { "add", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void cmd_alias_add_shows_usage_when_no_value(void **state)
{
    gchar *args[] = { "add", "alias", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void cmd_alias_remove_shows_usage_when_no_args(void **state)
{
    gchar *args[] = { "remove", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void cmd_alias_show_usage_when_invalid_subcmd(void **state)
{
    gchar *args[] = { "blah", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void cmd_alias_add_adds_alias(void **state)
{
    gchar *args[] = { "add", "hc", "/help commands", NULL };

    expect_cons_show("Command alias added /hc -> /help commands");

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);

    char *returned_val = prefs_get_alias("hc");
    assert_string_equal("/help commands", returned_val);
}

void cmd_alias_add_shows_message_when_exists(void **state)
{
    gchar *args[] = { "add", "hc", "/help commands", NULL };

    cmd_init();
    prefs_add_alias("hc", "/help commands");
    cmd_ac_add("/hc");

    expect_cons_show("Command or alias '/hc' already exists.");

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void cmd_alias_remove_removes_alias(void **state)
{
    gchar *args[] = { "remove", "hn", NULL };

    prefs_add_alias("hn", "/help navigation");

    expect_cons_show("Command alias removed -> /hn");

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);

    char *returned_val = prefs_get_alias("hn");
    assert_null(returned_val);
}

void cmd_alias_remove_shows_message_when_no_alias(void **state)
{
    gchar *args[] = { "remove", "hn", NULL };

    expect_cons_show("No such command alias /hn");

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void cmd_alias_list_shows_all_aliases(void **state)
{
    gchar *args[] = { "list", NULL };

    prefs_add_alias("vy", "/vercheck on");
    prefs_add_alias("q", "/quit");
    prefs_add_alias("hn", "/help navigation");
    prefs_add_alias("hc", "/help commands");
    prefs_add_alias("vn", "/vercheck off");

    // write a custom checker to check the correct list is passed
    expect_any(cons_show_aliases, aliases);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}