Permalink
Browse files

Merge pull request #3 from rbrainard/master

update unit tests with updated buildpack assertions and line spacing
  • Loading branch information...
2 parents 95c5789 + 72eeb5f commit 9205474dbdc3019b37878dd52b11b562fac57934 @naaman naaman committed Jan 21, 2012
Showing with 43 additions and 46 deletions.
  1. +24 −30 test/compile_test.sh
  2. +15 −12 test/detect_test.sh
  3. +4 −4 test/release_test.sh
View
54 test/compile_test.sh 100755 → 100644
@@ -39,30 +39,29 @@ testCompile()
{
createPom "$(withDependency)" # including dependency to force use of s3pository.heroku.com
- capture ${BUILDPACK_HOME}/bin/compile ${BUILD_DIR} ${CACHE_DIR}
- assertEquals 0 "${rtrn}"
- assertEquals "" "$(cat ${STD_ERR})"
+ compile
+
+ assertCapturedSuccess
- assertContains "Installing Maven 3.0.3" "$(cat ${STD_OUT})"
+ assertCaptured "Installing Maven 3.0.3"
assertFileMD5 "605f8b746e16576064258afaf630a2cc" ${CACHE_DIR}/.maven/bin/mvn
assertTrue "mvn should be executable" "[ -x ${CACHE_DIR}/.maven/bin/mvn ]"
- assertContains "Installing settings.xml" "$(cat ${STD_OUT})"
+ assertCaptured "Installing settings.xml"
assertFileMD5 "a5fa7b9982fc64939c0e215f935a850a" ${CACHE_DIR}/.m2/settings.xml
- assertContains "executing $CACHE_DIR/.maven/bin/mvn -B -Duser.home=$BUILD_DIR -Dmaven.repo.local=$CACHE_DIR/.m2/repository -s $CACHE_DIR/.m2/settings.xml -DskipTests=true clean install" "$(cat ${STD_OUT})"
- assertContains "s3pository.heroku.com" "$(cat ${STD_OUT})"
- assertContains "BUILD SUCCESS" "$(cat ${STD_OUT})"
+ assertCaptured "executing $CACHE_DIR/.maven/bin/mvn -B -Duser.home=$BUILD_DIR -Dmaven.repo.local=$CACHE_DIR/.m2/repository -s $CACHE_DIR/.m2/settings.xml -DskipTests=true clean install"
+ assertCaptured "s3pository.heroku.com"
+ assertCaptured "BUILD SUCCESS"
}
testCompilationFailure()
{
# Don't create POM to fail build
- capture ${BUILDPACK_HOME}/bin/compile ${BUILD_DIR} ${CACHE_DIR}
- assertEquals 1 "${rtrn}"
- assertContains "Failed to build app with Maven" "$(cat ${STD_OUT})"
- assertEquals "" "$(cat ${STD_ERR})"
+ compile
+
+ assertCapturedError "Failed to build app with Maven"
}
testDownloadCaching()
@@ -74,11 +73,11 @@ testDownloadCaching()
mkdir -p ${CACHE_DIR}/.m2
echo "OLD SETTINGS" > ${CACHE_DIR}/.m2/settings.xml
- capture ${BUILDPACK_HOME}/bin/compile ${BUILD_DIR} ${CACHE_DIR}
+ compile
- assertNotContains "Maven should not be installed again when already cached" "Installing Maven" "$(cat ${STD_OUT})"
- assertContains "settings.xml should always be installed" "Installing settings.xml" "$(cat ${STD_OUT})"
- assertNotContains "existing settings.xml file should have been replaced" "OLD SETTINGS" "$(cat ${CACHE_DIR}/.m2/settings.xml)"
+ assertNotCaptured "Maven should not be installed again when already cached" "Installing Maven"
+ assertCaptured "settings.xml should always be installed" "Installing settings.xml"
+ assertFileNotContains "existing settings.xml file should have been replaced" "OLD SETTINGS" "${CACHE_DIR}/.m2/settings.xml"
}
testNewAppsRemoveM2Cache()
@@ -89,10 +88,9 @@ testNewAppsRemoveM2Cache()
assertFalse "Precondition: New apps should not have a CACHE_DIR prior to running" "[ -d ${CACHE_DIR} ]"
assertFalse "Precondition: New apps should not have a removeM2Cache file prior to running" "[ -f ${CACHE_DIR}/removeM2Cache ]"
- capture ${BUILDPACK_HOME}/bin/compile ${BUILD_DIR} ${CACHE_DIR}
- assertEquals 0 "${rtrn}"
- assertEquals "" "$(cat ${STD_ERR})"
+ compile
+ assertCapturedSuccess
assertTrue "removeM2Cache file should now exist in cache" "[ -f ${CACHE_DIR}/removeM2Cache ]"
assertFalse ".m2 should not be copied to build dir" "[ -d ${BUILD_DIR}/.m2 ]"
assertFalse ".maven should not be copied to build dir" "[ -d ${BUILD_DIR}/.maven ]"
@@ -106,10 +104,9 @@ testNonLegacyExistingAppsRemoveCache()
assertTrue "Precondition: Existing apps should have a CACHE_DIR from previous run" "[ -d ${CACHE_DIR} ]"
assertTrue "Precondition: Existing apps should have a removeM2Cache file from previous run" "[ -f ${CACHE_DIR}/removeM2Cache ]"
- capture ${BUILDPACK_HOME}/bin/compile ${BUILD_DIR} ${CACHE_DIR}
- assertEquals 0 "${rtrn}"
- assertEquals "" "$(cat ${STD_ERR})"
-
+ compile
+
+ assertCapturedSuccess
assertTrue "removeM2Cache file should still exist in cache" "[ -f ${CACHE_DIR}/removeM2Cache ]"
assertFalse ".m2 should not be copied to build dir" "[ -d ${BUILD_DIR}/.m2 ]"
assertFalse ".maven should not be copied to build dir" "[ -d ${BUILD_DIR}/.maven ]"
@@ -120,15 +117,12 @@ testLegacyAppsKeepM2Cache()
createPom
assertTrue "Precondition: Legacy apps should have a CACHE_DIR from a previous run" "[ -d ${CACHE_DIR} ]"
- assertFalse "Precondition: Legacy apps should not have a removeM2Cache file" "[ -f ${CACHE_DIR}/removeM2Cache ]"
+ assertFalse "Precondition: Legacy apps should not have a removeM2Cache file" "[ -f ${CACHE_DIR}/removeM2Cache ]"
- capture ${BUILDPACK_HOME}/bin/compile ${BUILD_DIR} ${CACHE_DIR}
- assertEquals 0 "${rtrn}"
- assertEquals "" "$(cat ${STD_ERR})"
-
- # assertContains "language_pack_java retain_m2_repo" "` cat /var/log/system.log`"
+ compile
+
+ assertCapturedSuccess
assertFalse "removeM2Cache file should not exist in cache" "[ -f ${CACHE_DIR}/removeM2Cache ]"
assertEquals ".m2 should be copied to build dir" "" "$(diff -r ${CACHE_DIR}/.m2 ${BUILD_DIR}/.m2)"
assertEquals ".maven should be copied to build dir" "" "$(diff -r ${CACHE_DIR}/.maven ${BUILD_DIR}/.maven)"
}
-
View
27 test/detect_test.sh 100755 → 100644
@@ -5,21 +5,24 @@
testDetect()
{
touch ${BUILD_DIR}/pom.xml
-
- capture ${BUILDPACK_HOME}/bin/detect ${BUILD_DIR}
-
- assertEquals 0 ${rtrn}
- assertEquals "Java" "$(cat ${STD_OUT})"
- assertNull "$(cat ${STD_ERR})"
+
+ detect
+
+ assertAppDetected "Java"
}
testNoDetectMissingPomFile()
{
- touch ${BUILD_DIR}/build.xml
+ detect
+
+ assertNoAppDetected
+}
+
+testNoDetectPomFileAsDir()
+{
+ mkdir -p ${BUILD_DIR}/pom.xml
+
+ detect
- capture ${BUILDPACK_HOME}/bin/detect ${BUILD_DIR}
-
- assertEquals 1 ${rtrn}
- assertEquals "no" "$(cat ${STD_OUT})"
- assertNull "$(cat ${STD_ERR})"
+ assertNoAppDetected
}
View
8 test/release_test.sh 100755 → 100644
@@ -16,8 +16,8 @@ addons:
EOF`
- capture ${BUILDPACK_HOME}/bin/release ${BUILD_DIR}
- assertEquals 0 ${rtrn}
- assertEquals "${expected_release_output}" "$(cat ${STD_OUT})"
- assertEquals "" "$(cat ${STD_ERR})"
+ release
+
+ assertCapturedSuccess
+ assertCaptured "${expected_release_output}"
}

0 comments on commit 9205474

Please sign in to comment.