forked from kindleit/heroku-buildpack-scala-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
executable file
·88 lines (71 loc) · 1.92 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
#
# Create a Heroku app with the following buildpack:
# https://github.com/ddollar/buildpack-test
#
# Push this Node.js buildpack to that Heroku app to
# run the tests
#
testDetectWithPackageJson() {
detect "package-json-version"
assertCaptured "Node.js"
assertCapturedSuccess
}
testDetectWithoutPackageJson() {
detect "no-package-json"
assertCapturedError 1 ""
}
testPackageJsonWithVersion() {
compile "package-json-version"
assertNotCaptured "WARNING: No version of Node.js specified"
assertCaptured "Using Node.js version: 0.6.11"
assertCaptured "Using npm version: 1.1.9"
assertCapturedSuccess
}
testPackageJsonWithoutVersion() {
compile "package-json-noversion"
assertCaptured "WARNING: No version of Node.js specified"
assertCaptured "Using Node.js version: 0.10"
assertCaptured "Using npm version: 1.2"
assertCapturedSuccess
}
testPackageJsonWithInvalidVersion() {
compile "package-json-invalidversion"
assertCapturedError 1 "Requested engine npm version 1.1.5 does not"
}
testNothingCached() {
cache=$(mktmpdir)
compile "package-json-version" $cache
assertCapturedSuccess
assertEquals "0" "$(ls -1 $cache | wc -l)"
}
testProfileCreated() {
compile "package-json-version"
assertCaptured "Building runtime environment"
assertFile "export PATH=\"\$HOME/bin:\$HOME/node_modules/.bin:\$PATH\"" ".profile.d/nodejs.sh"
assertCapturedSuccess
}
## utils ########################################
pushd $(dirname 0) >/dev/null
BASE=$(pwd)
popd >/dev/null
source ${BASE}/vendor/test-utils/test-utils
mktmpdir() {
dir=$(mktemp -t testXXXXX)
rm -rf $dir
mkdir $dir
echo $dir
}
detect() {
capture ${BASE}/bin/detect ${BASE}/test/$1
}
COMPILE_DIR=""
compile() {
COMPILE_DIR=$(mktmpdir)
cp -r ${BASE}/test/$1/* ${COMPILE_DIR}/
capture ${BASE}/bin/compile ${COMPILE_DIR} $2
}
assertFile() {
assertEquals "$1" "$(cat ${COMPILE_DIR}/$2)"
}
source ${BASE}/vendor/shunit2/shunit2