github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/cli/apiresources_test.go (about) 1 package cli 2 3 import ( 4 "regexp" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 10 "k8s.io/cli-runtime/pkg/genericclioptions" 11 ) 12 13 func TestAPIResources(t *testing.T) { 14 f := newServerFixture(t) 15 16 streams, _, out, _ := genericclioptions.NewTestIOStreams() 17 cmd := newApiresourcesCmd(streams) 18 cmd.register() 19 20 err := cmd.run(f.ctx, nil) 21 require.NoError(t, err) 22 23 // output spacing is dependent on longest resource name, so a regex is used to keep this test 24 // from being overly brittle 25 outputRe := regexp.MustCompile(`filewatches[ ]+fw[ ]+tilt.dev/v1alpha1[ ]+false[ ]+FileWatch`) 26 27 cmdOutput := out.String() 28 assert.Truef(t, outputRe.MatchString(cmdOutput), 29 "Command output was not as expected. Output:\n%s\n", cmdOutput) 30 }