-
Notifications
You must be signed in to change notification settings - Fork 293
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 #1866 from dlion/1799-fix-rebasable-logic-and-test
Fix the rebasable flag logic in case of missing label
- Loading branch information
Showing
9 changed files
with
159 additions
and
18 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
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,59 @@ | ||
package dist_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/heroku/color" | ||
"github.com/pkg/errors" | ||
"github.com/sclevine/spec" | ||
"github.com/sclevine/spec/report" | ||
|
||
"github.com/buildpacks/pack/internal/builder/fakes" | ||
"github.com/buildpacks/pack/pkg/dist" | ||
h "github.com/buildpacks/pack/testhelpers" | ||
) | ||
|
||
func TestImage(t *testing.T) { | ||
color.Disable(true) | ||
defer color.Disable(false) | ||
spec.Run(t, "testImage", testImage, spec.Parallel(), spec.Report(report.Terminal{})) | ||
} | ||
|
||
func testImage(t *testing.T, when spec.G, it spec.S) { | ||
when("A label needs to be get", func() { | ||
it("sets a label successfully", func() { | ||
var outputLabel bool | ||
mockInspectable := fakes.FakeInspectable{ReturnForLabel: "true", ErrorForLabel: nil} | ||
|
||
isPresent, err := dist.GetLabel(&mockInspectable, "random-label", &outputLabel) | ||
|
||
h.AssertNil(t, err) | ||
h.AssertEq(t, isPresent, true) | ||
h.AssertEq(t, outputLabel, true) | ||
}) | ||
|
||
it("returns an error", func() { | ||
var outputLabel bool | ||
mockInspectable := fakes.FakeInspectable{ReturnForLabel: "", ErrorForLabel: errors.New("random-error")} | ||
|
||
isPresent, err := dist.GetLabel(&mockInspectable, "random-label", &outputLabel) | ||
|
||
h.AssertNotNil(t, err) | ||
h.AssertEq(t, isPresent, false) | ||
h.AssertEq(t, outputLabel, false) | ||
}) | ||
}) | ||
|
||
when("Try to get an empty label", func() { | ||
it("returns isPresent but it doesn't set the label", func() { | ||
var outputLabel bool | ||
mockInspectable := fakes.FakeInspectable{ReturnForLabel: "", ErrorForLabel: nil} | ||
|
||
isPresent, err := dist.GetLabel(&mockInspectable, "random-label", &outputLabel) | ||
|
||
h.AssertNil(t, err) | ||
h.AssertEq(t, isPresent, false) | ||
h.AssertEq(t, outputLabel, false) | ||
}) | ||
}) | ||
} |