github.com/dnephin/dobi@v0.15.0/cmd/list_test.go (about) 1 package cmd 2 3 import ( 4 "testing" 5 6 "github.com/dnephin/dobi/config" 7 testconfig "github.com/dnephin/dobi/internal/test/config" 8 "gotest.tools/v3/assert" 9 is "gotest.tools/v3/assert/cmp" 10 ) 11 12 func TestInclude(t *testing.T) { 13 var testcases = []struct { 14 doc string 15 opts listOptions 16 resource config.Resource 17 expected bool 18 }{ 19 { 20 resource: &testconfig.FakeResource{}, 21 expected: false, 22 }, 23 { 24 opts: listOptions{all: true}, 25 resource: &testconfig.FakeResource{}, 26 expected: true, 27 }, 28 { 29 opts: listOptions{tags: []string{"one"}}, 30 resource: &testconfig.FakeResource{}, 31 expected: false, 32 }, 33 { 34 opts: listOptions{tags: []string{"one"}}, 35 resource: &testconfig.FakeResource{ 36 Annotations: config.Annotations{ 37 Annotations: config.AnnotationFields{Description: "foo"}, 38 }, 39 }, 40 expected: false, 41 }, 42 { 43 opts: listOptions{tags: []string{"one"}}, 44 resource: &testconfig.FakeResource{ 45 Annotations: config.Annotations{ 46 Annotations: config.AnnotationFields{ 47 Tags: []string{"one", "two"}, 48 }, 49 }, 50 }, 51 expected: true, 52 }, 53 } 54 55 for _, testcase := range testcases { 56 actual := include(testcase.resource, testcase.opts) 57 assert.Check(t, is.Equal(testcase.expected, actual)) 58 } 59 }