aboutsummaryrefslogtreecommitdiffstats
path: root/cache/query_test.go
blob: 9ae62ac474f8bcc3976dc3aa6c29ff93e587f271 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cache

import "testing"

func TestQueryParse(t *testing.T) {

	var tests = []struct {
		input string
		ok    bool
	}{
		{"gibberish", false},

		{"status:", false},

		{"status:open", true},
		{"status:closed", true},
		{"status:unknown", false},

		{"author:rene", true},
		{`author:"René Descartes"`, true},

		{"actor:bernhard", true},
		{"participant:leonhard", true},

		{"label:hello", true},
		{`label:"Good first issue"`, true},

		{"title:titleOne", true},
		{`title:"Bug titleTwo"`, true},

		{"sort:edit", true},
		{"sort:unknown", false},
	}

	for _, test := range tests {
		_, err := ParseQuery(test.input)
		if (err == nil) != test.ok {
			t.Fatalf("Unexpected parse result, expected: %v, err: %v", test.ok, err)
		}
	}
}