Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Busko <pavel.busko@sap.com>
  • Loading branch information
pbusko committed May 3, 2024
1 parent 7e8685b commit 9b8cd1b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
4 changes: 0 additions & 4 deletions phase/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_ARCH=amd64")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_ARCH_VARIANT=")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_OS=linux")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_DISTRO_NAME=")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_DISTRO_VERSION=")
return buildpack.BuildOutputs{}, nil
},
)
Expand All @@ -205,8 +203,6 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_ARCH=amd64")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_ARCH_VARIANT=")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_OS=linux")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_DISTRO_NAME=")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_DISTRO_VERSION=")
return buildpack.BuildOutputs{}, nil
})

Expand Down
4 changes: 2 additions & 2 deletions phase/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_ARCH=amd64")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_ARCH_VARIANT=")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_OS=linux")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_DISTRO_NAME=")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_DISTRO_VERSION=")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_DISTRO_NAME=ubuntu")
h.AssertContains(t, inputs.TargetEnv, "CNB_TARGET_DISTRO_VERSION=22.04")
return buildpack.DetectOutputs{}
})

Expand Down
8 changes: 4 additions & 4 deletions phase/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ func testGenerator(t *testing.T, when spec.G, it spec.S) {
h.AssertContains(t, inputs.TargetEnv,
"CNB_TARGET_ARCH=amd64",
"CNB_TARGET_ARCH_VARIANT=",
"CNB_TARGET_DISTRO_NAME=",
"CNB_TARGET_DISTRO_VERSION=",
"CNB_TARGET_DISTRO_NAME=ubuntu",
"CNB_TARGET_DISTRO_VERSION=22.04",
"CNB_TARGET_OS=linux",
)
return buildpack.GenerateOutputs{Dockerfiles: []buildpack.DockerfileInfo{{ExtensionID: d.Extension.ID,
Expand All @@ -296,8 +296,8 @@ func testGenerator(t *testing.T, when spec.G, it spec.S) {
h.AssertContains(t, inputs.TargetEnv,
"CNB_TARGET_ARCH=amd64",
"CNB_TARGET_ARCH_VARIANT=",
"CNB_TARGET_DISTRO_NAME=",
"CNB_TARGET_DISTRO_VERSION=",
"CNB_TARGET_DISTRO_NAME=ubuntu",
"CNB_TARGET_DISTRO_VERSION=22.04",
"CNB_TARGET_OS=linux",
)
return buildpack.GenerateOutputs{Dockerfiles: []buildpack.DockerfileInfo{{ExtensionID: d.Extension.ID,
Expand Down
7 changes: 3 additions & 4 deletions platform/run_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func testRunImage(t *testing.T, when spec.G, it spec.S) {
t: t,
HasFile: false,
}
observed := platform.EnvVarsFor(d, tm, nil)
observed := platform.EnvVarsFor(d, tm, &log.Logger{Handler: memory.New()})
h.AssertContains(t, observed, "CNB_TARGET_ARCH="+tm.Arch)
h.AssertContains(t, observed, "CNB_TARGET_ARCH_VARIANT="+tm.ArchVariant)
h.AssertContains(t, observed, "CNB_TARGET_DISTRO_NAME="+tm.Distro.Name)
Expand All @@ -221,14 +221,13 @@ func testRunImage(t *testing.T, when spec.G, it spec.S) {
})

it("returns the right thing from /etc/os-release", func() {
logr := &log.Logger{Handler: memory.New()}
d := &mockDetector{
contents: "this is just test contents really",
t: t,
HasFile: true,
}
tm := files.TargetMetadata{Arch: "pentium", ArchVariant: "mmx", ID: "my-id", OS: "linux", Distro: nil}
observed := platform.EnvVarsFor(d, tm, logr)
observed := platform.EnvVarsFor(d, tm, &log.Logger{Handler: memory.New()})
h.AssertContains(t, observed, "CNB_TARGET_ARCH="+tm.Arch)
h.AssertContains(t, observed, "CNB_TARGET_ARCH_VARIANT="+tm.ArchVariant)
h.AssertContains(t, observed, "CNB_TARGET_DISTRO_NAME=opensesame")
Expand All @@ -244,7 +243,7 @@ func testRunImage(t *testing.T, when spec.G, it spec.S) {
t: t,
HasFile: false,
}
observed := platform.EnvVarsFor(d, tm, nil)
observed := platform.EnvVarsFor(d, tm, &log.Logger{Handler: memory.New()})
h.AssertContains(t, observed, "CNB_TARGET_ARCH="+tm.Arch)
h.AssertContains(t, observed, "CNB_TARGET_OS="+tm.OS)
// note: per the spec only the ID field is optional, so I guess the others should always be set: https://github.com/buildpacks/rfcs/blob/main/text/0096-remove-stacks-mixins.md#runtime-metadata
Expand Down

0 comments on commit 9b8cd1b

Please sign in to comment.