diff --git a/fakes/get_etc_passwd_file_content.go b/fakes/get_etc_passwd_file_content.go deleted file mode 100644 index 4c60b90..0000000 --- a/fakes/get_etc_passwd_file_content.go +++ /dev/null @@ -1,7 +0,0 @@ -package fakes - -func Get_etc_passwd_file_content(etcPasswdFileContent string) func() (string, error) { - return func() (string, error) { - return etcPasswdFileContent, nil - } -} diff --git a/generate.go b/generate.go index b138bac..950748d 100644 --- a/generate.go +++ b/generate.go @@ -60,12 +60,12 @@ func NewDuringBuildPermissionsGetter(epfg EtcPasswdFileContentGetter) DuringBuil return DuringBuildPermissionsGetter{get_etc_passwd_file_content: epfg} } -func Generate(dependencyManager DependencyManager, logger scribe.Emitter, p DuringBuildPermissionsGetter) packit.GenerateFunc { +func Generate(dependencyManager DependencyManager, logger scribe.Emitter, duringBuildPermissionsGetter DuringBuildPermissionsGetter) packit.GenerateFunc { return func(context packit.GenerateContext) (packit.GenerateResult, error) { logger.Title("%s %s", context.Info.Name, context.Info.Version) logger.Process("Resolving Node Engine version") - duringBuildPermissions, err := p.duringBuildPermissionsGetter() + duringBuildPermissions, err := duringBuildPermissionsGetter.duringBuildPermissionsGetter() if err != nil { return packit.GenerateResult{}, err } diff --git a/generate_test.go b/generate_test.go index b5cf0fc..8baa354 100644 --- a/generate_test.go +++ b/generate_test.go @@ -14,7 +14,6 @@ import ( "github.com/paketo-buildpacks/packit/cargo" "github.com/paketo-buildpacks/packit/v2" ubinodejsextension "github.com/paketo-community/ubi-nodejs-extension" - "github.com/paketo-community/ubi-nodejs-extension/fakes" "github.com/sclevine/spec" "github.com/paketo-buildpacks/packit/v2/scribe" @@ -39,6 +38,12 @@ type BuildDockerfileProps struct { //go:embed templates/build.Dockerfile var buildDockerfileTemplate string +func mocked_get_etc_passwd_file_content(etcPasswdFileContent string) func() (string, error) { + return func() (string, error) { + return etcPasswdFileContent, nil + } +} + func testFillPropsToTemplate(t *testing.T, context spec.G, it spec.S) { var ( @@ -126,7 +131,7 @@ func testGenerate(t *testing.T, context spec.G, it spec.S) { workingDir = t.TempDir() Expect(err).NotTo(HaveOccurred()) - p := ubinodejsextension.NewDuringBuildPermissionsGetter(fakes.Get_etc_passwd_file_content(`root:x:0:0:root:/root:/bin/bash + p := ubinodejsextension.NewDuringBuildPermissionsGetter(mocked_get_etc_passwd_file_content(`root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin @@ -175,7 +180,7 @@ cnb:x:1001:1000::/home/cnb:/bin/bash workingDir = t.TempDir() cnbDir, err = os.MkdirTemp("", "cnb") - p := ubinodejsextension.NewDuringBuildPermissionsGetter(fakes.Get_etc_passwd_file_content(`root:x:0:0:root:/root:/bin/bash + p := ubinodejsextension.NewDuringBuildPermissionsGetter(mocked_get_etc_passwd_file_content(`root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin @@ -565,7 +570,7 @@ cnb:x:1001:1000::/home/cnb:/bin/bash workingDir = t.TempDir() Expect(err).NotTo(HaveOccurred()) - p := ubinodejsextension.NewDuringBuildPermissionsGetter(fakes.Get_etc_passwd_file_content("")) + p := ubinodejsextension.NewDuringBuildPermissionsGetter(mocked_get_etc_passwd_file_content("")) generate = ubinodejsextension.Generate(dependencyManager, logger, p) err = toml.NewEncoder(buf).Encode(testBuildPlan) @@ -708,7 +713,7 @@ cnb:x:1001:1000::/home/cnb:/bin/bash workingDir = t.TempDir() cnbDir, err = os.MkdirTemp("", "cnb") - p := ubinodejsextension.NewDuringBuildPermissionsGetter(fakes.Get_etc_passwd_file_content(`root:x:0:0:root:/root:/bin/bash + p := ubinodejsextension.NewDuringBuildPermissionsGetter(mocked_get_etc_passwd_file_content(`root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin diff --git a/run/main.go b/run/main.go index fc6913f..2443cbb 100644 --- a/run/main.go +++ b/run/main.go @@ -14,10 +14,10 @@ import ( func main() { dependencyManager := postal.NewService(cargo.NewTransport()) logEmitter := scribe.NewEmitter(os.Stdout).WithLevel(os.Getenv("BP_LOG_LEVEL")) - p := ubinodejsextension.NewDuringBuildPermissionsGetter(ubinodejsextension.Get_etc_passwd_file_content) + duringBuildPermissionsGetter := ubinodejsextension.NewDuringBuildPermissionsGetter(ubinodejsextension.Get_etc_passwd_file_content) packit.RunExtension( ubinodejsextension.Detect(), - ubinodejsextension.Generate(dependencyManager, logEmitter, p), + ubinodejsextension.Generate(dependencyManager, logEmitter, duringBuildPermissionsGetter), ) }