-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb0a4a2
commit a249429
Showing
6 changed files
with
166 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"github.com/buildpacks/libcnb" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestInjectingALayerEnvironmentWithPrepend(t *testing.T) { | ||
writer := new(bytes.Buffer) | ||
command := Make(writer, "env") | ||
|
||
environment := make(libcnb.Environment) | ||
environment["TEST_ENV.prepend"] = "A_TEST_VARIABLE" | ||
|
||
InjectLayerEnvironment(command, environment) | ||
|
||
err := command.Run() | ||
if err != nil { | ||
t.Errorf("%s", err) | ||
} | ||
if !strings.Contains(writer.String(), "TEST_ENV") && !strings.Contains(writer.String(), "A_TEST_VARIABLE") { | ||
t.Fatalf("Output did not contain TEST_ENV") | ||
} | ||
} | ||
|
||
func TestInjectingALayerEnvironmentWithAppend(t *testing.T) { | ||
writer := new(bytes.Buffer) | ||
command := Make(writer, "env") | ||
|
||
environment := make(libcnb.Environment) | ||
environment["TEST_ENV.append"] = "A_TEST_VARIABLE" | ||
|
||
InjectLayerEnvironment(command, environment) | ||
|
||
err := command.Run() | ||
if err != nil { | ||
t.Errorf("%s", err) | ||
} | ||
if !strings.Contains(writer.String(), "TEST_ENV") && !strings.Contains(writer.String(), "A_TEST_VARIABLE") { | ||
t.Fatalf("Output did not contain TEST_ENV") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestMakingACommandWithoutArguments(t *testing.T) { | ||
writer := new(bytes.Buffer) | ||
command := Make(writer, "ls") | ||
|
||
err := command.Run() | ||
if err != nil { | ||
t.Errorf("%s", err) | ||
} | ||
if !strings.Contains(writer.String(), "make_test.go") { | ||
t.Fatalf("Output did not contain make_test.go") | ||
} | ||
} | ||
|
||
func TestMakingACommandWithArguments(t *testing.T) { | ||
writer := new(bytes.Buffer) | ||
command := Make(writer, "ls", "../") | ||
|
||
err := command.Run() | ||
if err != nil { | ||
t.Errorf("%s", err) | ||
} | ||
if !strings.Contains(writer.String(), "command") { | ||
t.Fatalf("Output did not contain command") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package command | ||
|
||
import ( | ||
"bytes" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestRunningACommandWithoutArguments(t *testing.T) { | ||
writer := new(bytes.Buffer) | ||
err := Run(writer, "ls") | ||
if err != nil { | ||
t.Errorf("%s", err) | ||
} | ||
if !strings.Contains(writer.String(), "make_test.go") { | ||
t.Fatalf("Output did not contain make_test.go") | ||
} | ||
} | ||
|
||
func TestRunningACommandWithArguments(t *testing.T) { | ||
writer := new(bytes.Buffer) | ||
err := Run(writer, "ls", "../") | ||
if err != nil { | ||
t.Errorf("%s", err) | ||
} | ||
if !strings.Contains(writer.String(), "command") { | ||
t.Fatalf("Output did not contain command") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
module github.com/acodeninja/buildpacks | ||
|
||
go 1.22.1 | ||
go 1.23 | ||
|
||
toolchain go1.23.2 | ||
|
||
require ( | ||
github.com/buildpacks/libcnb v1.30.3 | ||
github.com/fatih/color v1.16.0 | ||
github.com/paketo-buildpacks/libpak v1.69.1 | ||
github.com/BurntSushi/toml v1.4.0 | ||
github.com/buildpacks/libcnb v1.30.4 | ||
github.com/paketo-buildpacks/libpak v1.72.0 | ||
) | ||
|
||
require ( | ||
github.com/BurntSushi/toml v1.3.2 // indirect | ||
github.com/Masterminds/semver/v3 v3.2.1 // indirect | ||
github.com/creack/pty v1.1.21 // indirect | ||
github.com/Masterminds/semver/v3 v3.3.0 // indirect | ||
github.com/creack/pty v1.1.24 // indirect | ||
github.com/heroku/color v0.0.6 // indirect | ||
github.com/imdario/mergo v0.3.16 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect | ||
github.com/onsi/gomega v1.33.0 // indirect | ||
golang.org/x/sys v0.18.0 // indirect | ||
github.com/onsi/gomega v1.35.1 // indirect | ||
golang.org/x/sys v0.26.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters