about summary refs log tree commit diff stats
path: root/filters
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-07-07 22:43:57 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-08 16:06:26 -0400
commit88c379dcbaaf9fd549cd271817e79fe634b1dd84 (patch)
tree5b12c811aa5a96ebe8debc1cb4067e32ea237698 /filters
parentcce7cb48081ca090ac2d3a0e781dfbc25d581946 (diff)
downloadaerc-88c379dcbaaf9fd549cd271817e79fe634b1dd84.tar.gz
Use []uint32 instead of imap.SeqSet
A sequence-set is an IMAP-specific implementation detail. Throughout the
UI, aerc simply operates using lists of opaque identifiers. In order to
loosen the coupling between the UI and IMAP in particular, replace most
usages of imap.SeqSet with []uint32, leaving the translation to a SeqSet
to the IMAP backend as needed.
Diffstat (limited to 'filters')
0 files changed, 0 insertions, 0 deletions
class='oid'>4bd06a5d ^
e089ffb1 ^
4bd06a5d ^
e089ffb1 ^
788fc48b ^
e089ffb1 ^






8dbe300d ^





















































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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169















                               
                            











                                                         
                        


































































                                                                  





                                                            
               
                                            
                                
 
                                                               






                                             





















































                                                                 
#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 "ui/ui.h"
#include "ui/mock_ui.h"

#include "config/preferences.h"

#include "command/command.h"
#include "command/commands.h"

void cmd_alias_add_shows_usage_when_no_args(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    help->usage = "some usage";
    gchar *args[] = { "add", NULL };

    expect_cons_show("Usage: some usage");

    gboolean result = cmd_alias(args, *help);
    assert_true(result);

    free(help);
}

void cmd_alias_add_shows_usage_when_no_value(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    help->usage = "some usage";
    gchar *args[] = { "add", "alias", NULL };

    expect_cons_show("Usage: some usage");

    gboolean result = cmd_alias(args, *help);
    assert_true(result);

    free(help);
}

void cmd_alias_remove_shows_usage_when_no_args(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    help->usage = "some usage";
    gchar *args[] = { "remove", NULL };

    expect_cons_show("Usage: some usage");

    gboolean result = cmd_alias(args, *help);
    assert_true(result);

    free(help);
}

void cmd_alias_show_usage_when_invalid_subcmd(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    help->usage = "some usage";
    gchar *args[] = { "blah", NULL };

    expect_cons_show("Usage: some usage");

    gboolean result = cmd_alias(args, *help);
    assert_true(result);

    free(help);
}

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

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

    gboolean result = cmd_alias(args, *help);

    char *returned_val = prefs_get_alias("hc");

    assert_true(result);
    assert_string_equal("/help commands", returned_val);

    free(help);
}

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

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

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

    gboolean result = cmd_alias(args, *help);
    assert_true(result);

    free(help);
}

void cmd_alias_remove_removes_alias(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "remove", "hn", NULL };

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

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

    gboolean result = cmd_alias(args, *help);

    char *returned_val = prefs_get_alias("hn");

    assert_true(result);
    assert_null(returned_val);

    free(help);
}

void cmd_alias_remove_shows_message_when_no_alias(void **state)
{
    mock_cons_show();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "remove", "hn", NULL };

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

    gboolean result = cmd_alias(args, *help);
    assert_true(result);

    free(help);
}

void cmd_alias_list_shows_all_aliases(void **state)
{
    mock_cons_show_aliases();
    CommandHelp *help = malloc(sizeof(CommandHelp));
    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_cons_show_aliases();

    gboolean result = cmd_alias(args, *help);
    assert_true(result);

    free(help);
}