Skip to content

Commit

Permalink
Merge pull request #3 from BarDweller/main
Browse files Browse the repository at this point in the history
Fix Test Case
  • Loading branch information
dmikusa committed Oct 16, 2023
2 parents 568c891 + e0a5689 commit 46011fa
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
. "github.com/onsi/gomega"
"github.com/paketo-buildpacks/libjvm/v2"
"github.com/paketo-buildpacks/libpak/v2"
"github.com/paketo-buildpacks/libpak/v2/log"
ubijavaextension "github.com/paketo-community/ubi-java-extension/v1"
"github.com/sclevine/spec"
)
Expand All @@ -22,11 +23,12 @@ type RunDockerfileProps struct {
var runDockerfileTemplate string

type BuildDockerfileProps struct {
JAVA_VERSION string
CNB_USER_ID int
CNB_GROUP_ID int
CNB_STACK_ID string
PACKAGES string
JAVA_EXTENSION_HELPERS string
JAVA_VERSION string
CNB_USER_ID int
CNB_GROUP_ID int
CNB_STACK_ID string
PACKAGES string
}

//go:embed templates/build.Dockerfile
Expand All @@ -43,11 +45,12 @@ func testFillPropsToTemplate(t *testing.T, context spec.G, it spec.S) {
it("Should fill with properties the template/build.Dockerfile", func() {

buildDockerfileProps := BuildDockerfileProps{
JAVA_VERSION: "17",
CNB_USER_ID: 1000,
CNB_GROUP_ID: 1000,
CNB_STACK_ID: "ubi8-paketo",
PACKAGES: "openssl-devel java-17-openjdk-devel nss_wrapper which",
JAVA_VERSION: "17",
CNB_USER_ID: 1000,
CNB_GROUP_ID: 1000,
CNB_STACK_ID: "ubi8-paketo",
PACKAGES: "openssl-devel java-17-openjdk-devel nss_wrapper which",
JAVA_EXTENSION_HELPERS: "helper1, helper2",
}

output, err := ubijavaextension.FillPropsToTemplate(buildDockerfileProps, buildDockerfileTemplate)
Expand All @@ -63,10 +66,10 @@ RUN echo ${build_id}
RUN microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install -y openssl-devel java-17-openjdk-devel nss_wrapper which && microdnf clean all
RUN echo uid:gid "1000:1000"
USER 1000:1000
RUN echo "17" > /bpi.paketo.ubi.java.version
RUN echo "helper1, helper2" > /bpi.paketo.ubi.java.helpers
RUN echo "CNB_STACK_ID: ubi8-paketo"`))
USER 1000:1000`))

})

Expand Down Expand Up @@ -107,6 +110,7 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) {

it("Java version 17 recognised", func() {
generateResult, err = ubijavaextension.Generate()(libjvm.GenerateContentContext{
Logger: log.NewDiscardLogger(),
ConfigurationResolver: libpak.ConfigurationResolver{Configurations: []libpak.BuildModuleConfiguration{
{Name: "BP_JVM_VERSION", Default: "17"},
}},
Expand All @@ -126,6 +130,7 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) {

it("Java version 1.8 recognised", func() {
generateResult, err = ubijavaextension.Generate()(libjvm.GenerateContentContext{
Logger: log.NewDiscardLogger(),
ConfigurationResolver: libpak.ConfigurationResolver{Configurations: []libpak.BuildModuleConfiguration{
{Name: "BP_JVM_VERSION", Default: "1.8"},
}},
Expand All @@ -145,6 +150,7 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) {

it("Java version 11 recognised", func() {
generateResult, err = ubijavaextension.Generate()(libjvm.GenerateContentContext{
Logger: log.NewDiscardLogger(),
ConfigurationResolver: libpak.ConfigurationResolver{Configurations: []libpak.BuildModuleConfiguration{
{Name: "BP_JVM_VERSION", Default: "11"},
}},
Expand Down

0 comments on commit 46011fa

Please sign in to comment.