github.com/pluralsh/plural-cli@v0.9.5/pkg/test/e2e/e2e_api_test.go (about) 1 //go:build e2e 2 3 package e2e_test 4 5 import ( 6 "fmt" 7 "os/exec" 8 "strings" 9 "testing" 10 11 "github.com/pluralsh/polly/containers" 12 13 "github.com/stretchr/testify/assert" 14 ) 15 16 func TestApiListInstallations(t *testing.T) { 17 18 cmd := exec.Command("plural", "api", "list", "installations") 19 cmdOutput, err := cmd.CombinedOutput() 20 if err != nil { 21 t.Fatal(err) 22 } 23 installations := make([]string, 0) 24 rows := strings.Split(string(cmdOutput[:]), "\n") 25 for _, row := range rows[1:] { // Skip the heading row and iterate through the remaining rows 26 row = strings.ReplaceAll(row, "|", "") 27 cols := strings.Fields(row) // Extract each column from the row. 28 if len(cols) == 3 { 29 installations = append(installations, cols[0]) 30 } 31 } 32 expected := []string{"etcd", "monitoring", "ingress-nginx", "postgres", "console", "bootstrap", "minio"} 33 expects := containers.ToSet(expected) 34 assert.True(t, expects.Equal(containers.ToSet(installations)), fmt.Sprintf("the expected %s is different then %s", expected, installations)) 35 }