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
|
package commands
import (
"reflect"
"testing"
"git.sr.ht/~rjarry/aerc/lib/state"
)
func TestExecuteCommand_expand(t *testing.T) {
tests := []struct {
args []string
want []string
}{
{
args: []string{"prompt", "Really quit? ", "quit"},
want: []string{"prompt", "Really quit? ", "quit"},
},
{
args: []string{"{{", "print", "\"hello\"", "}}"},
want: []string{"hello"},
},
{
args: []string{"prompt", "Really quit ? ", " quit "},
want: []string{"prompt", "Really quit ? ", " quit "},
},
{
args: []string{
"prompt", "Really quit? ", "{{",
"print", "\"quit\"", "}}",
},
want: []string{"prompt", "Really quit? ", "quit"},
},
{
args: []string{
"prompt", "Really quit? ", "{{",
"if", "1", "}}", "quit", "{{end}}",
},
want: []string{"prompt", "Really quit? ", "quit"},
},
}
data := state.TemplateData{}
for i, test := range tests {
got, err := expand(&data, test.args)
if err != nil {
t.Errorf("test %d failed with err: %v", i, err)
} else if !reflect.DeepEqual(got, test.want) {
t.Errorf("test %d failed: "+
"got: %v, but want: %v", i, got, test.want)
}
}
}
|