From ada2c291f2e3289958e41c0cfe981bec3ffb966f Mon Sep 17 00:00:00 2001 From: Sambhav Kothari Date: Wed, 31 Mar 2021 00:34:37 +0100 Subject: [PATCH] Fix acceptance tests for builders created by previous pack versions Signed-off-by: Sambhav Kothari --- acceptance/acceptance_test.go | 14 +++++----- acceptance/invoke/pack.go | 11 ++++++-- acceptance/invoke/pack_fixtures.go | 1 - ...t_0.18.0_builder_nested_depth_2_output.txt | 28 +++++++++---------- .../inspect_0.18.0_builder_nested_output.txt | 28 +++++++++---------- .../inspect_0.18.0_builder_output.txt | 20 ++++++------- 6 files changed, 53 insertions(+), 49 deletions(-) diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 681167f316..3100eb2931 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/acceptance/invoke/pack.go b/acceptance/invoke/pack.go index d69f465c71..08c22a9bd0 100644 --- a/acceptance/invoke/pack.go +++ b/acceptance/invoke/pack.go @@ -8,6 +8,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "strings" "sync" "testing" @@ -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() { diff --git a/acceptance/invoke/pack_fixtures.go b/acceptance/invoke/pack_fixtures.go index 65d7ea44d4..00dc458f76 100644 --- a/acceptance/invoke/pack_fixtures.go +++ b/acceptance/invoke/pack_fixtures.go @@ -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) diff --git a/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_nested_depth_2_output.txt b/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_nested_depth_2_output.txt index 91c7ab5ea3..2983811715 100644 --- a/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_nested_depth_2_output.txt +++ b/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_nested_depth_2_output.txt @@ -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: @@ -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: diff --git a/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_nested_output.txt b/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_nested_output.txt index 704e14cda6..7d89856068 100644 --- a/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_nested_output.txt +++ b/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_nested_output.txt @@ -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: @@ -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: diff --git a/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_output.txt b/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_output.txt index fefa49715a..7590eaee9f 100644 --- a/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_output.txt +++ b/acceptance/testdata/pack_fixtures/inspect_0.18.0_builder_output.txt @@ -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: @@ -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: