-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from jromero/feature/137
'set-default-builder' should suggest builders
- Loading branch information
Showing
6 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package commands_test | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/sclevine/spec" | ||
"github.com/sclevine/spec/report" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/buildpack/pack/commands" | ||
"github.com/buildpack/pack/logging" | ||
h "github.com/buildpack/pack/testhelpers" | ||
) | ||
|
||
func TestSetDefaultBuilder(t *testing.T) { | ||
spec.Run(t, "Commands", testSetDefaultBuilderCommand, spec.Parallel(), spec.Report(report.Terminal{})) | ||
} | ||
|
||
func testSetDefaultBuilderCommand(t *testing.T, when spec.G, it spec.S) { | ||
|
||
var ( | ||
command *cobra.Command | ||
logger *logging.Logger | ||
outBuf bytes.Buffer | ||
) | ||
|
||
it.Before(func() { | ||
logger = logging.NewLogger(&outBuf, &outBuf, false, false) | ||
command = commands.SetDefaultBuilder(logger) | ||
}) | ||
|
||
when("#SetDefaultBuilder", func() { | ||
when("no builder provided", func() { | ||
it("display suggested builders", func() { | ||
command.SetArgs([]string{}) | ||
h.AssertNil(t, command.Execute()) | ||
h.AssertContains(t, outBuf.String(), "Suggested builders:") | ||
}) | ||
}) | ||
|
||
when("empty builder name is provided", func() { | ||
it("display suggested builders", func() { | ||
command.SetArgs([]string{}) | ||
h.AssertNil(t, command.Execute()) | ||
h.AssertContains(t, outBuf.String(), "Suggested builders:") | ||
}) | ||
}) | ||
}) | ||
} |