diff --git a/apps/app_staging_environment_test.go b/apps/app_staging_environment_test.go new file mode 100644 index 000000000..ff943510c --- /dev/null +++ b/apps/app_staging_environment_test.go @@ -0,0 +1,119 @@ +package apps + +import ( + "fmt" + "io/ioutil" + "os" + "path" + + . "github.com/cloudfoundry-incubator/cf-test-helpers/cf" + . "github.com/cloudfoundry-incubator/cf-test-helpers/generator" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" + archive_helpers "github.com/pivotal-golang/archiver/extractor/test_helper" +) + +var _ = Describe("Buildpack Environment", func() { + var ( + appName string + BuildpackName string + + appPath string + + buildpackPath string + buildpackArchivePath string + + tmpdir string + ) + + matchingFilename := func(appName string) string { + return fmt.Sprintf("buildpack-environment-match-%s", appName) + } + + BeforeEach(func() { + AsUser(context.AdminUserContext(), func() { + BuildpackName = RandomName() + appName = RandomName() + + var err error + tmpdir, err = ioutil.TempDir("", "buildpack_env") + Expect(err).ToNot(HaveOccurred()) + appPath, err = ioutil.TempDir(tmpdir, "matching-app") + Expect(err).ToNot(HaveOccurred()) + + buildpackPath, err = ioutil.TempDir(tmpdir, "matching-buildpack") + Expect(err).ToNot(HaveOccurred()) + + buildpackArchivePath = path.Join(buildpackPath, "buildpack.zip") + + archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{ + { + Name: "bin/compile", + Body: `#!/usr/bin/env bash + +echo RUBY_LOCATION=$(which ruby) +echo RUBY_VERSION=$(ruby --version) + +sleep 10 +`, + }, + { + Name: "bin/detect", + Body: fmt.Sprintf(`#!/bin/bash + +if [ -f "${1}/%s" ]; then + echo Simple +else + echo no + exit 1 +fi +`, matchingFilename(appName)), + }, + { + Name: "bin/release", + Body: `#!/usr/bin/env bash + +cat <