Skip to content

Commit

Permalink
Implemented Unit Testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphoting committed Jul 5, 2012
1 parent 4c59d2a commit ea6ae8f
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,35 @@ heroku config:add BUILDPACK_URL=git://github.com/iphoting/heroku-buildpack-php-t

Push deploy your app and you should see Nginx, mcrypt, and PHP being bundled.


Testing the Buildpack
---------------------
Setup the test environment on Heroku as follows:
```
$ cd heroku-buildpack-php-tyler/
$ heroku create -s cedar -b git://github.com/ryanbrainard/heroku-buildpack-testrunner.git
Creating deep-thought-1234... done, stack is cedar
http://deep-thought-1234.herokuapp.com/ | git@heroku.com:deep-thought-1234.git
Git remote heroku added
```

Then, push the buildpack to be tested into Heroku:
```
$ git push -f heroku <branch>:master # where <branch> is the git branch you want to test.
```

Finally, run those tests:
```
$ heroku run tests
```

If you run your tests programatically, you might need the follow command instead:
```
$ heroku run tests | bin/report
```

Source: <https://github.com/ryanbrainard/heroku-buildpack-testrunner>

Credits
-------

Expand Down
43 changes: 43 additions & 0 deletions test/compile_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh

. ${BUILDPACK_HOME}/support/set-env.sh

testCompile()
{
compile

assertCapturedSuccess

assertCaptured "-----> Installing Nginx"
assertCaptured "-----> Bundling Nginx v${NGINX_VERSION}"
assertTrue "nginx should be executable" "[ -x ${BUILD_DIR}/vendor/nginx/sbin/nginx ]"

assertCaptured "-----> Installing libmcrypt"
assertCaptured "-----> Bundling libmcrypt v${LIBMCRYPT_VERSION}"
assertTrue "libmcrypt should exist" "[ -e ${BUILD_DIR}/local/lib/libmcrypt.so ]"

assertCaptured "-----> Installing libmemcached"
assertCaptured "-----> Bundling libmemcached v${LIBMEMCACHED_VERSION}"
assertTrue "libmemcached should exist" "[ -e ${BUILD_DIR}/local/lib/libmemcached.so ]"

assertCaptured "-----> Installing PHP"
assertCaptured "-----> Bundling PHP v${PHP_VERSION}"
assertTrue "php-fpm should be executable" "[ -x ${BUILD_DIR}/vendor/php/sbin/php-fpm ]"

assertCaptured "-----> Installing newrelic"
assertCaptured "-----> Bundling newrelic daemon v${NEWRELIC_VERSION}"
assertTrue "newrelic-daemon should be executable" "[ -x ${BUILD_DIR}/local/bin/newrelic-daemon ]"

assertCaptured "-----> Copying config files"
assertTrue "php-fpm.conf exists and readable" "[ -r ${BUILD_DIR}/vendor/php/etc/php-fpm.conf ]"
assertTrue "php.ini exists and readable" "[ -r ${BUILD_DIR}/vendor/php/php.ini ]"
assertTrue "php/etc.d/ directory exists" "[ -d ${BUILD_DIR}/vendor/php/etc.d/ ]"
assertTrue "nginx.conf.erb exists and readable" "[ -r ${BUILD_DIR}/vendor/nginx/conf/nginx.conf.erb ]"

assertCaptured "-----> Installing boot script"
assertTrue "boot.sh exists and executable" "[ -x ${BUILD_DIR}/boot.sh ]"

assertCaptured "-----> Done with compile"
}
24 changes: 24 additions & 0 deletions test/detect_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh

testDetect()
{
mkdir -p ${BUILD_DIR}/
touch ${BUILD_DIR}/index.php

detect

assertCapturedSuccess
assertAppDetected "PHP"
}

testNoDetectPHP()
{
mkdir -p ${BUILD_DIR}/

detect

assertCapturedError 1 "no"
assertNoAppDetected
}

0 comments on commit ea6ae8f

Please sign in to comment.