Skip to content

Commit

Permalink
* Fix detect script to work on mac, for local development
Browse files Browse the repository at this point in the history
* Added test scripts for each buildpack phase
* Testing done for detect and release :easy:
  • Loading branch information
Naaman Newbold committed Jan 18, 2012
1 parent b1c2bf9 commit 0e29eb9
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/detect
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# bin/use <build-dir>

play_confs=`cd $1; find -wholename "*/conf/application.conf" ! -wholename "*modules*" -type f`
play_confs=`cd $1; find . -wholename "*/conf/application.conf" ! -wholename "*modules*" -type f`
if [ -n "$play_confs" ]; then
echo "Play!" && exit 0
else
Expand Down
18 changes: 18 additions & 0 deletions test/compile_test.sh
@@ -0,0 +1,18 @@
#!/bin/sh

#. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh

#PLAY_URL="https://s3.amazonaws.com/heroku-jvm-langpack-play/play-heroku-$VER_TO_INSTALL.tar.gz"

# test cache is unpacked
# test play version is picked up correctly in PLAY_VERSION from dependencies.yml
# test play is installed correctly
# test an upgrade of play version
# test a valid version of play that isn't in S3
# test a fake version of play
# test ivysettings.xml is removed and our custom settings are used
# test dependencies are correctly retrieved
# test precompile phase compiles artifacts
# test play gets put into cache after precompile
# test modules and ivy deps from build time are removed and not included in the slug
# test a warning is printed if no procfile is present
26 changes: 26 additions & 0 deletions test/detect_test.sh
@@ -0,0 +1,26 @@
#!/bin/sh

source ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh

testDetectWithConfFileDetectsPlayApp() {
mkdir -p ${BUILD_DIR}/play-app/conf
touch ${BUILD_DIR}/play-app/conf/application.conf
detect

assertAppDetected "Play!"
}

testNoConfFileDoesNotDetectPlayApp() {
mkdir -p ${BUILD_DIR}/play-app/conf
detect

assertNoAppDetected
}

testConfFileWithModulesDirectoryDoesNotDetectPlayApp() {
mkdir -p ${BUILD_DIR}/play-app/modules/conf
touch ${BUILD_DIR}/play-app/modules/conf/application.conf
detect

assertNoAppDetected
}
39 changes: 39 additions & 0 deletions test/release_test.sh
@@ -0,0 +1,39 @@
#!/bin/sh

source ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh

# test with procfile
# test without procfile

testReleasedYamlDoesNotIncludeDefaultProcWhenProcfileIsPresent() {
touch ${BUILD_DIR}/Procfile
expectedReleaseYAML=`cat <<EOF
---
config_vars:
PATH: .play:.tools:/usr/local/bin:/usr/bin:/bin
JAVA_OPTS: -Xmx384m
PLAY_OPTS: --%prod -Dprecompiled=true
addons:
shared-database:5mb
EOF`
releaseYAML=`release`
assertEquals "${expectedReleaseYAML}" "$(cat ${STD_OUT})"
}
testReleasedYamlHasDefaultProcessType() {
expectedReleaseYAML=`cat <<EOF
---
config_vars:
PATH: .play:.tools:/usr/local/bin:/usr/bin:/bin
JAVA_OPTS: -Xmx384m
PLAY_OPTS: --%prod -Dprecompiled=true
addons:
shared-database:5mb
default_process_types:
web: play run --http.port=\\$PORT \\$PLAY_OPTS
EOF`
releaseYAML=`release`
assertEquals "${expectedReleaseYAML}" "$(cat ${STD_OUT})"
}

0 comments on commit 0e29eb9

Please sign in to comment.