2018-09-09 21:21:49 +03:00
|
|
|
package cache
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestQueryParse(t *testing.T) {
|
2018-09-10 13:47:05 +03:00
|
|
|
|
2018-09-09 21:21:49 +03:00
|
|
|
var tests = []struct {
|
|
|
|
input string
|
|
|
|
ok bool
|
|
|
|
}{
|
|
|
|
{"gibberish", false},
|
|
|
|
|
|
|
|
{"status:", false},
|
|
|
|
|
|
|
|
{"status:open", true},
|
|
|
|
{"status:closed", true},
|
|
|
|
{"status:unknown", false},
|
|
|
|
|
|
|
|
{"author:rene", true},
|
2018-09-10 13:47:05 +03:00
|
|
|
{`author:"René Descartes"`, true},
|
2018-09-09 21:21:49 +03:00
|
|
|
|
2018-09-10 12:12:22 +03:00
|
|
|
{"label:hello", true},
|
2018-09-10 13:47:05 +03:00
|
|
|
{`label:"Good first issue"`, true},
|
2018-09-10 12:12:22 +03:00
|
|
|
|
2019-03-01 17:30:07 +03:00
|
|
|
{"title:Bug titleOne", true},
|
|
|
|
{`title:"Bug titleTwo"`, true},
|
|
|
|
|
2018-09-10 12:12:22 +03:00
|
|
|
{"sort:edit", true},
|
|
|
|
{"sort:unknown", false},
|
2018-09-09 21:21:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|