github.com/buildpacks/pack@v0.33.3-0.20240516162812-884dd1837311/internal/commands/stack_test.go (about) 1 package commands 2 3 import ( 4 "bytes" 5 "testing" 6 7 "github.com/sclevine/spec" 8 "github.com/sclevine/spec/report" 9 "github.com/spf13/cobra" 10 11 "github.com/buildpacks/pack/pkg/logging" 12 h "github.com/buildpacks/pack/testhelpers" 13 ) 14 15 func TestStackCommand(t *testing.T) { 16 spec.Run(t, "StackCommand", testStackCommand, spec.Parallel(), spec.Report(report.Terminal{})) 17 } 18 19 func testStackCommand(t *testing.T, when spec.G, it spec.S) { 20 var ( 21 command *cobra.Command 22 outBuf bytes.Buffer 23 ) 24 25 it.Before(func() { 26 command = NewStackCommand(logging.NewLogWithWriters(&outBuf, &outBuf)) 27 }) 28 29 when("#Stack", func() { 30 it("displays stack information", func() { 31 command.SetArgs([]string{}) 32 bb := bytes.NewBufferString("") // In most tests we don't seem to need to this, not sure why it's necessary here. 33 command.SetOut(bb) 34 h.AssertNil(t, command.Execute()) 35 h.AssertEq(t, bb.String(), `(Deprecated) 36 Stacks are deprecated in favor of using BuildImages and RunImages directly, but will continue to be supported throughout all of 2023 and '24 if not longer. Please see our docs for more details- https://buildpacks.io/docs/concepts/components/stack 37 38 Usage: 39 stack [command] 40 41 Available Commands: 42 completion Generate the autocompletion script for the specified shell 43 help Help about any command 44 suggest (deprecated) List the recommended stacks 45 46 Flags: 47 -h, --help help for stack 48 49 Use "stack [command] --help" for more information about a command. 50 `) 51 }) 52 }) 53 }