Skip to content

Commit

Permalink
Fix acceptance tests for builders created by previous pack versions
Browse files Browse the repository at this point in the history
Signed-off-by: Sambhav Kothari <[email protected]>
  • Loading branch information
sambhav committed Mar 30, 2021
1 parent ec52af5 commit ada2c29
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 49 deletions.
14 changes: 7 additions & 7 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]

expectedOutput := pack.FixtureManager().TemplateVersionedFixture(
"inspect_%s_builder_nested_output.txt",
createBuilderPack.Version(),
createBuilderPack.SanitizedVersion(),
"inspect_builder_nested_output.txt",
map[string]interface{}{
"builder_name": builderName,
Expand Down Expand Up @@ -2031,7 +2031,7 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]

expectedOutput := pack.FixtureManager().TemplateVersionedFixture(
"inspect_%s_builder_nested_depth_2_output.txt",
createBuilderPack.Version(),
createBuilderPack.SanitizedVersion(),
"inspect_builder_nested_depth_2_output.txt",
map[string]interface{}{
"builder_name": builderName,
Expand Down Expand Up @@ -2072,7 +2072,7 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]

expectedOutput := pack.FixtureManager().TemplateVersionedFixture(
"inspect_%s_builder_nested_output_toml.txt",
createBuilderPack.Version(),
createBuilderPack.SanitizedVersion(),
"inspect_builder_nested_output_toml.txt",
map[string]interface{}{
"builder_name": builderName,
Expand Down Expand Up @@ -2109,7 +2109,7 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]

expectedOutput := pack.FixtureManager().TemplateVersionedFixture(
"inspect_%s_builder_nested_output_yaml.txt",
createBuilderPack.Version(),
createBuilderPack.SanitizedVersion(),
"inspect_builder_nested_output_yaml.txt",
map[string]interface{}{
"builder_name": builderName,
Expand Down Expand Up @@ -2150,7 +2150,7 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]

expectedOutput := pack.FixtureManager().TemplateVersionedFixture(
"inspect_%s_builder_nested_output_json.txt",
createBuilderPack.Version(),
createBuilderPack.SanitizedVersion(),
"inspect_builder_nested_output_json.txt",
map[string]interface{}{
"builder_name": builderName,
Expand Down Expand Up @@ -2189,7 +2189,7 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]

expectedOutput := pack.FixtureManager().TemplateVersionedFixture(
"inspect_%s_builder_output.txt",
createBuilderPack.Version(),
createBuilderPack.SanitizedVersion(),
"inspect_builder_output.txt",
map[string]interface{}{
"builder_name": builderName,
Expand Down Expand Up @@ -2229,7 +2229,7 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]

expectedOutput := pack.FixtureManager().TemplateVersionedFixture(
"inspect_%s_builder_output.txt",
createBuilderPack.Version(),
createBuilderPack.SanitizedVersion(),
"inspect_builder_output.txt",
map[string]interface{}{
"builder_name": builderName,
Expand Down
11 changes: 8 additions & 3 deletions acceptance/invoke/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -167,10 +168,14 @@ func (c *InterruptCmd) Wait() error {

func (i *PackInvoker) Version() string {
i.testObject.Helper()
return strings.TrimSpace(i.RunSuccessfully("version"))
}

output := i.RunSuccessfully("version")

return strings.TrimSpace(output)
func (i *PackInvoker) SanitizedVersion() string {
i.testObject.Helper()
// Sanitizing any git commit sha and build number from the version output
re := regexp.MustCompile(`\d+\.\d+\.\d+`)
return re.FindString(strings.TrimSpace(i.RunSuccessfully("version")))
}

func (i *PackInvoker) EnableExperimental() {
Expand Down
1 change: 0 additions & 1 deletion acceptance/invoke/pack_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (m PackFixtureManager) TemplateVersionedFixture(
templateData map[string]interface{},
) string {
m.testObject.Helper()

outputTemplate, err := ioutil.ReadFile(m.VersionedFixtureOrFallbackLocation(versionedPattern, version, fallback))
m.assert.Nil(err)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
simple/nested-level-1 nested-l1-version -
simple/nested-level-2 nested-l2-version -
ID NAME VERSION HOMEPAGE
noop.buildpack - noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack - noop.buildpack.version -
read/env - read-env-version -
simple/layers - simple-layers-version -
simple/nested-level-1 - nested-l1-version -
simple/nested-level-2 - nested-l2-version -

Detection Order:
└ Group #1:
Expand Down Expand Up @@ -77,13 +77,13 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
simple/nested-level-1 nested-l1-version -
simple/nested-level-2 nested-l2-version -
ID NAME VERSION HOMEPAGE
noop.buildpack - noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack - noop.buildpack.version -
read/env - read-env-version -
simple/layers - simple-layers-version -
simple/nested-level-1 - nested-l1-version -
simple/nested-level-2 - nested-l2-version -

Detection Order:
└ Group #1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
simple/nested-level-1 nested-l1-version -
simple/nested-level-2 nested-l2-version -
ID NAME VERSION HOMEPAGE
noop.buildpack - noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack - noop.buildpack.version -
read/env - read-env-version -
simple/layers - simple-layers-version -
simple/nested-level-1 - nested-l1-version -
simple/nested-level-2 - nested-l2-version -

Detection Order:
└ Group #1:
Expand Down Expand Up @@ -79,13 +79,13 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
simple/nested-level-1 nested-l1-version -
simple/nested-level-2 nested-l2-version -
ID NAME VERSION HOMEPAGE
noop.buildpack - noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack - noop.buildpack.version -
read/env - read-env-version -
simple/layers - simple-layers-version -
simple/nested-level-1 - nested-l1-version -
simple/nested-level-2 - nested-l2-version -

Detection Order:
└ Group #1:
Expand Down
20 changes: 10 additions & 10 deletions acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
ID NAME VERSION HOMEPAGE
noop.buildpack - noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack - noop.buildpack.version -
read/env - read-env-version -
simple/layers - simple-layers-version -

Detection Order:
└ Group #1:
Expand Down Expand Up @@ -73,11 +73,11 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
ID NAME VERSION HOMEPAGE
noop.buildpack - noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack - noop.buildpack.version -
read/env - read-env-version -
simple/layers - simple-layers-version -

Detection Order:
└ Group #1:
Expand Down

0 comments on commit ada2c29

Please sign in to comment.