Skip to content

Commit

Permalink
Add test to verify ruby version used for staging
Browse files Browse the repository at this point in the history
[#71367862]

Signed-off-by: Michael Fraenkel <[email protected]>
  • Loading branch information
sykesm authored and Michael Fraenkel committed May 23, 2014
1 parent 98a17bc commit 74c85d7
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions apps/app_staging_environment_test.go
Original file line number Diff line number Diff line change
@@ -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 <<EOF
---
config_vars:
PATH: bin:/usr/local/bin:/usr/bin:/bin
FROM_BUILD_PACK: "yes"
default_process_types:
web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "hi from a simple admin buildpack"; } | nc -l \$PORT; done
EOF
`,
},
})
_, err = os.Create(path.Join(appPath, matchingFilename(appName)))
Expect(err).ToNot(HaveOccurred())

_, err = os.Create(path.Join(appPath, "some-file"))
Expect(err).ToNot(HaveOccurred())

createBuildpack := Cf("create-buildpack", BuildpackName, buildpackArchivePath, "0").Wait(DEFAULT_TIMEOUT)
Expect(createBuildpack).Should(Exit(0))
Expect(createBuildpack).Should(Say("Creating"))
Expect(createBuildpack).Should(Say("OK"))
Expect(createBuildpack).Should(Say("Uploading"))
Expect(createBuildpack).Should(Say("OK"))
})
})

AfterEach(func() {
AsUser(context.AdminUserContext(), func() {
Expect(Cf("delete-buildpack", BuildpackName, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})

os.RemoveAll(tmpdir)
})

It("uses ruby 1.9.3-p547 for staging", func() {
push := Cf("push", appName, "-p", appPath).Wait(CF_PUSH_TIMEOUT)
Expect(push).To(Exit(0))
Expect(push).To(Say("RUBY_LOCATION=/usr/bin/ruby"))
Expect(push).To(Say("RUBY_VERSION=ruby 1.9.3p547"))
})

})

0 comments on commit 74c85d7

Please sign in to comment.