github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/cli/explain_test.go (about) 1 package cli 2 3 import ( 4 "bytes" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 10 "k8s.io/cli-runtime/pkg/genericclioptions" 11 12 "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" 13 ) 14 15 func TestExplain(t *testing.T) { 16 f := newServerFixture(t) 17 18 err := f.client.Create(f.ctx, &v1alpha1.Cmd{ 19 ObjectMeta: metav1.ObjectMeta{Name: "my-sleep"}, 20 Spec: v1alpha1.CmdSpec{ 21 Args: []string{"sleep", "1"}, 22 }, 23 }) 24 require.NoError(t, err) 25 26 out := bytes.NewBuffer(nil) 27 streams := genericclioptions.IOStreams{Out: out} 28 29 explain := newExplainCmd(streams) 30 explain.register() 31 32 err = explain.run(f.ctx, []string{"cmd"}) 33 require.NoError(t, err) 34 35 assert.Contains(t, out.String(), `Cmd represents a process on the host machine.`) 36 }