2021-09-27 10:32:05 +02:00
|
|
|
//go:build integration
|
2021-08-18 12:10:55 +02:00
|
|
|
// +build integration
|
2021-09-27 10:32:05 +02:00
|
|
|
|
2021-08-18 12:10:55 +02:00
|
|
|
// can be execute with go test -tags=integration ./integration/...
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNpmProject(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
|
|
|
Image: "paketobuildpacks/builder:full",
|
|
|
|
User: "cnb",
|
|
|
|
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
|
|
|
})
|
|
|
|
|
2021-08-26 14:26:54 +02:00
|
|
|
container.whenRunningPiperCommand("cnbBuild", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", "test")
|
2021-08-18 12:10:55 +02:00
|
|
|
|
|
|
|
container.assertHasOutput(t, "running command: /cnb/lifecycle/detector")
|
|
|
|
container.assertHasOutput(t, "Paketo NPM Start Buildpack")
|
2021-08-26 14:26:54 +02:00
|
|
|
container.assertHasOutput(t, "Saving test/not-found:0.0.1")
|
|
|
|
container.assertHasOutput(t, "failed to write image to the following tags: [test/not-found:0.0.1")
|
2021-08-18 12:10:55 +02:00
|
|
|
}
|
2021-09-14 15:38:58 +02:00
|
|
|
|
2021-09-27 10:32:05 +02:00
|
|
|
func TestZipPath(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
|
|
|
Image: "paketobuildpacks/builder:full",
|
|
|
|
User: "cnb",
|
|
|
|
TestDir: []string{"testdata", "TestCnbIntegration", "zip"},
|
|
|
|
})
|
|
|
|
|
|
|
|
container.whenRunningPiperCommand("cnbBuild", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", "test", "--path", "go.zip")
|
|
|
|
|
|
|
|
container.assertHasOutput(t, "running command: /cnb/lifecycle/detector")
|
|
|
|
container.assertHasOutput(t, "Installing Go")
|
|
|
|
container.assertHasOutput(t, "Paketo Go Build Buildpack")
|
|
|
|
container.assertHasOutput(t, "Saving test/not-found:0.0.1")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNonZipPath(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
|
|
|
Image: "paketobuildpacks/builder:full",
|
|
|
|
User: "cnb",
|
|
|
|
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
|
|
|
})
|
|
|
|
|
|
|
|
container.whenRunningPiperCommand("cnbBuild", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", "test", "--path", "mta.yaml")
|
|
|
|
|
|
|
|
container.assertHasOutput(t, "Copying 'mta.yaml' into '/workspace' failed: application path must be a directory or zip")
|
|
|
|
}
|
|
|
|
|
2021-09-14 16:14:50 +02:00
|
|
|
func TestNpmCustomBuildpacksFullProject(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
|
|
|
Image: "paketobuildpacks/builder:full",
|
|
|
|
User: "cnb",
|
|
|
|
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
|
|
|
})
|
|
|
|
|
|
|
|
container.whenRunningPiperCommand("cnbBuild", "--buildpacks", "gcr.io/paketo-buildpacks/nodejs", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", "test")
|
|
|
|
|
|
|
|
container.assertHasOutput(t, "Setting custom buildpacks: '[gcr.io/paketo-buildpacks/nodejs]'")
|
|
|
|
container.assertHasOutput(t, "Downloading buildpack 'gcr.io/paketo-buildpacks/nodejs' to /tmp/nodejs")
|
|
|
|
container.assertHasOutput(t, "running command: /cnb/lifecycle/detector")
|
|
|
|
container.assertHasOutput(t, "Paketo NPM Start Buildpack")
|
|
|
|
container.assertHasOutput(t, "Saving test/not-found:0.0.1")
|
|
|
|
container.assertHasOutput(t, "failed to write image to the following tags: [test/not-found:0.0.1")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNpmCustomBuildpacksBuildpacklessProject(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
|
|
|
Image: "paketobuildpacks/builder:buildpackless-full",
|
|
|
|
User: "cnb",
|
|
|
|
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
|
|
|
})
|
|
|
|
|
|
|
|
container.whenRunningPiperCommand("cnbBuild", "--buildpacks", "gcr.io/paketo-buildpacks/nodejs", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", "test")
|
|
|
|
|
|
|
|
container.assertHasOutput(t, "Setting custom buildpacks: '[gcr.io/paketo-buildpacks/nodejs]'")
|
|
|
|
container.assertHasOutput(t, "Downloading buildpack 'gcr.io/paketo-buildpacks/nodejs' to /tmp/nodejs")
|
|
|
|
container.assertHasOutput(t, "running command: /cnb/lifecycle/detector")
|
|
|
|
container.assertHasOutput(t, "Paketo NPM Start Buildpack")
|
|
|
|
container.assertHasOutput(t, "Saving test/not-found:0.0.1")
|
|
|
|
container.assertHasOutput(t, "failed to write image to the following tags: [test/not-found:0.0.1")
|
|
|
|
}
|
|
|
|
|
2021-09-14 15:38:58 +02:00
|
|
|
func TestWrongBuilderProject(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
|
|
|
Image: "nginx:latest",
|
|
|
|
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
|
|
|
})
|
|
|
|
|
|
|
|
container.whenRunningPiperCommand("cnbBuild", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", "test")
|
|
|
|
|
|
|
|
container.assertHasOutput(t, "the provided dockerImage is not a valid builder")
|
|
|
|
}
|