...
1 package bazel
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 )
8
9 func TestParseQueryResults(t *testing.T) {
10 regularQueryResult := []byte(`
11 //cmd/f8n/dennis:container_push
12 //cmd/f8n/dennis:container_push_target
13 //cmd/f8n/dennis:dennis
14 //cmd/f8n/dennis:dennis_container
15 //cmd/f8n/dennis:dennis_container.binary
16 //cmd/f8n/dennis:dennis_lib
17
18 `)
19
20 tcs := map[string]struct {
21 input []byte
22 expected []string
23 }{
24 "empty": {[]byte(""), nil},
25 "empty new line": {[]byte("\n"), nil},
26 "standard": {
27 regularQueryResult,
28 []string{
29 "//cmd/f8n/dennis:container_push",
30 "//cmd/f8n/dennis:container_push_target",
31 "//cmd/f8n/dennis:dennis",
32 "//cmd/f8n/dennis:dennis_container",
33 "//cmd/f8n/dennis:dennis_container.binary",
34 "//cmd/f8n/dennis:dennis_lib",
35 },
36 },
37 }
38
39 for name, tc := range tcs {
40 t.Run(name, func(t *testing.T) {
41 actual := parseQueryOutput(tc.input)
42 assert.Equal(t, tc.expected, actual)
43 })
44 }
45 }
46
View as plain text