Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 89 lines (71 sloc) 1.976 kB
5b75769 @ddollar add unit tests
ddollar authored
1 #!/usr/bin/env bash
2
3 #
4 # Create a Heroku app with the following buildpack:
5 # https://github.com/ddollar/buildpack-test
6 #
a8a953e @ddollar prettify
ddollar authored
7 # Push this Node.js buildpack to that Heroku app to
8 # run the tests
5b75769 @ddollar add unit tests
ddollar authored
9 #
10
11 testDetectWithPackageJson() {
a8a953e @ddollar prettify
ddollar authored
12 detect "package-json-version"
5b75769 @ddollar add unit tests
ddollar authored
13 assertCaptured "Node.js"
14 assertCapturedSuccess
15 }
16
17 testDetectWithoutPackageJson() {
a8a953e @ddollar prettify
ddollar authored
18 detect "no-package-json"
5b75769 @ddollar add unit tests
ddollar authored
19 assertCapturedError 1 ""
20 }
21
22 testPackageJsonWithVersion() {
a8a953e @ddollar prettify
ddollar authored
23 compile "package-json-version"
c09c3f8 @ddollar add a warning of no version of node.js specified in package.json
ddollar authored
24 assertNotCaptured "WARNING: No version of Node.js specified"
5b75769 @ddollar add unit tests
ddollar authored
25 assertCaptured "Using Node.js version: 0.6.11"
26 assertCaptured "Using npm version: 1.1.9"
27 assertCapturedSuccess
28 }
29
8140120 @ddollar consistency
ddollar authored
30 testPackageJsonWithoutVersion() {
a8a953e @ddollar prettify
ddollar authored
31 compile "package-json-noversion"
c09c3f8 @ddollar add a warning of no version of node.js specified in package.json
ddollar authored
32 assertCaptured "WARNING: No version of Node.js specified"
5b75769 @ddollar add unit tests
ddollar authored
33 assertCaptured "Using Node.js version: 0.4.7"
34 assertCaptured "Using npm version: 1.0.106"
35 assertCapturedSuccess
36 }
37
4986728 @ddollar add test for invalid engine version
ddollar authored
38 testPackageJsonWithInvalidVersion() {
39 compile "package-json-invalidversion"
40 assertCapturedError 1 "Requested engine npm version 1.1.5 does not"
41 }
42
85170d5 @ddollar test that nothing is cached
ddollar authored
43 testNothingCached() {
44 cache=$(mktmpdir)
45 compile "package-json-version" $cache
46 assertCapturedSuccess
47 assertEquals "0" "$(ls -1 $cache | wc -l)"
48 }
49
c269de9 @ddollar assert creation of the profile.d script
ddollar authored
50 testProfileCreated() {
51 compile "package-json-version"
52 assertCaptured "Building runtime environment"
faee766 @ddollar Revert "make it fail"
ddollar authored
53 assertFile "export PATH=\"\$HOME/bin:\$HOME/node_modules/.bin:\$PATH\"" ".profile.d/nodejs.sh"
c269de9 @ddollar assert creation of the profile.d script
ddollar authored
54 assertCapturedSuccess
55 }
56
5b75769 @ddollar add unit tests
ddollar authored
57 ## utils ########################################
58
59 pushd $(dirname 0) >/dev/null
60 BASE=$(pwd)
61 popd >/dev/null
62
63 source ${BASE}/vendor/test-utils/test-utils
64
85170d5 @ddollar test that nothing is cached
ddollar authored
65 mktmpdir() {
66 dir=$(mktemp -t testXXXXX)
67 rm -rf $dir
68 mkdir $dir
69 echo $dir
70 }
71
5b75769 @ddollar add unit tests
ddollar authored
72 detect() {
73 capture ${BASE}/bin/detect ${BASE}/test/$1
74 }
75
9aacac8 @ddollar allow files to be asserted after compile
ddollar authored
76 COMPILE_DIR=""
77
5b75769 @ddollar add unit tests
ddollar authored
78 compile() {
9aacac8 @ddollar allow files to be asserted after compile
ddollar authored
79 COMPILE_DIR=$(mktmpdir)
80 cp -r ${BASE}/test/$1/* ${COMPILE_DIR}/
81 capture ${BASE}/bin/compile ${COMPILE_DIR} $2
82 }
83
84 assertFile() {
85 assertEquals "$1" "$(cat ${COMPILE_DIR}/$2)"
5b75769 @ddollar add unit tests
ddollar authored
86 }
87
88 source ${BASE}/vendor/shunit2/shunit2
Something went wrong with that request. Please try again.