github.com/zaquestion/lab@v0.25.1/cmd/label_list_test.go (about) 1 package cmd 2 3 import ( 4 "os/exec" 5 "strings" 6 "testing" 7 8 "github.com/stretchr/testify/require" 9 ) 10 11 func Test_labelList(t *testing.T) { 12 t.Parallel() 13 repo := copyTestRepo(t) 14 cmd := exec.Command(labBinaryPath, "label", "list") 15 cmd.Dir = repo 16 17 b, err := cmd.CombinedOutput() 18 if err != nil { 19 t.Fatal(err) 20 } 21 22 labels := strings.Split(string(b), "\n") 23 t.Log(labels) 24 require.Contains(t, labels, "bug") 25 require.Contains(t, labels, "confirmed") 26 require.Contains(t, labels, "critical") 27 } 28 29 func Test_labelListSearch(t *testing.T) { 30 t.Parallel() 31 repo := copyTestRepo(t) 32 cmd := exec.Command(labBinaryPath, "label", "list", "bug") 33 cmd.Dir = repo 34 35 b, err := cmd.CombinedOutput() 36 if err != nil { 37 t.Fatal(err) 38 } 39 40 labels := strings.Split(string(b), "\n") 41 t.Log(labels) 42 require.Contains(t, labels, "bug") 43 require.NotContains(t, labels, "confirmed") 44 } 45 46 func Test_labelListSearchCaseInsensitive(t *testing.T) { 47 t.Parallel() 48 repo := copyTestRepo(t) 49 cmd := exec.Command(labBinaryPath, "label", "list", "BUG") 50 cmd.Dir = repo 51 52 b, err := cmd.CombinedOutput() 53 if err != nil { 54 t.Fatal(err) 55 } 56 57 labels := strings.Split(string(b), "\n") 58 t.Log(labels) 59 require.Contains(t, labels, "bug") 60 require.NotContains(t, labels, "confirmed") 61 }