Skip to content

Commit

Permalink
fix acceptance tests
Browse files Browse the repository at this point in the history
Signed-off-by: Joey Brown <[email protected]>
  • Loading branch information
joeybrown-sf committed Dec 4, 2024
1 parent 55cb637 commit 3479ced
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
19 changes: 18 additions & 1 deletion acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,24 @@ func testAcceptance(
imageManager.CleanupImages(runImageName)
})

it("fails with a message", func() {
h.SkipIf(t, pack.SupportsFeature(invoke.StackWarning), "stack is validated in prior versions")
output, err := pack.Run(
"build", repoName,
"-p", filepath.Join("testdata", "mock_app"),
"--run-image", runImageName,
)
assert.NotNil(err)

assertOutput := assertions.NewOutputAssertionManager(t, output)
assertOutput.ReportsRunImageStackNotMatchingBuilder(
"other.stack.id",
"pack.test.stack",
)
})

it("succeeds with a warning", func() {
h.SkipIf(t, !pack.SupportsFeature(invoke.StackWarning), "stack is no longer validated")
output, err := pack.Run(
"build", repoName,
"-p", filepath.Join("testdata", "mock_app"),
Expand All @@ -2194,7 +2211,7 @@ func testAcceptance(
assert.Nil(err)

assertOutput := assertions.NewOutputAssertionManager(t, output)
assertOutput.ReportsRunImageStackNotMatchingBuilder()
assertOutput.ReportsDeprecatedUseOfStack()
})
})
})
Expand Down
11 changes: 10 additions & 1 deletion acceptance/assertions/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,16 @@ func (o OutputAssertionManager) ReportsSkippingRestore() {
o.assert.Contains(o.output, "Skipping 'restore' due to clearing cache")
}

func (o OutputAssertionManager) ReportsRunImageStackNotMatchingBuilder() {
func (o OutputAssertionManager) ReportsRunImageStackNotMatchingBuilder(runImageStack, builderStack string) {
o.testObject.Helper()

o.assert.Contains(
o.output,
fmt.Sprintf("run-image stack id '%s' does not match builder stack '%s'", runImageStack, builderStack),
)
}

func (o OutputAssertionManager) ReportsDeprecatedUseOfStack() {
o.testObject.Helper()

o.assert.Contains(o.output, "Warning: deprecated usage of stack")
Expand Down
4 changes: 4 additions & 0 deletions acceptance/invoke/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ const (
ManifestCommands
PlatformOption
MultiPlatformBuildersAndBuildPackages
StackWarning
)

var featureTests = map[Feature]func(i *PackInvoker) bool{
Expand Down Expand Up @@ -286,6 +287,9 @@ var featureTests = map[Feature]func(i *PackInvoker) bool{
MultiPlatformBuildersAndBuildPackages: func(i *PackInvoker) bool {
return i.atLeast("v0.34.0")
},
StackWarning: func(i *PackInvoker) bool {
return !i.atLeast("v0.37.0")
},
}

func (i *PackInvoker) SupportsFeature(f Feature) bool {
Expand Down

0 comments on commit 3479ced

Please sign in to comment.