Skip to content

Commit

Permalink
adds unit test for deprecated command to pacify codecov
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
  • Loading branch information
joe-kimmel-vmw committed Apr 11, 2023
1 parent 774a0dc commit 13a0b02
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions internal/commands/stack_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package commands

import (
"bytes"
"testing"

"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/spf13/cobra"

"github.com/buildpacks/pack/pkg/logging"
h "github.com/buildpacks/pack/testhelpers"
)

func TestStackCommand(t *testing.T) {
spec.Run(t, "StackCommand", testStackCommand, spec.Parallel(), spec.Report(report.Terminal{}))
}

func testStackCommand(t *testing.T, when spec.G, it spec.S) {
var (
command *cobra.Command
outBuf bytes.Buffer
)

it.Before(func() {
command = NewStackCommand(logging.NewLogWithWriters(&outBuf, &outBuf))
})

when("#Stack", func() {
it("displays stack information", func() {
command.SetArgs([]string{})
bb := bytes.NewBufferString("") // In most tests we don't seem to need to this, not sure why it's necessary here.
command.SetOut(bb)
h.AssertNil(t, command.Execute())
h.AssertEq(t, bb.String(), `(Deprecated)
Stacks will continue to be supported through at least 2024 but are deprecated in favor of using BuildImages and RunImages directly. Please see our docs for more details- https://buildpacks.io/docs/concepts/components/stack
Usage:
stack [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
suggest (deprecated) List the recommended stacks
Flags:
-h, --help help for stack
Use "stack [command] --help" for more information about a command.
`)
})
})
}

0 comments on commit 13a0b02

Please sign in to comment.