Skip to content

Commit

Permalink
Merge pull request heroku#4 from rbrainard/master
Browse files Browse the repository at this point in the history
update unit tests with updated buildpack assertions and line spacing
  • Loading branch information
naaman committed Jan 21, 2012
2 parents d1f6b49 + 99a5a48 commit 36cfb1a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
45 changes: 18 additions & 27 deletions test/compile_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,35 @@ testCompile()
touch ${CACHE_DIR}/.sbt_home/bin/sbt-launch-OLD.jar

compile

assertCapturedSuccess

# setup
assertTrue "Ivy2 cache should have been unpacked" "[ -f ${BUILD_DIR}/.sbt_home/.ivy2/testfile ]"
assertTrue "SBT bin cache should have been unpacked" "[ -f ${BUILD_DIR}/.sbt_home/bin/testfile ]"
assertTrue "Ivy2 cache should exist" "[ -d ${BUILD_DIR}/.ivy2/cache ]"
assertFalse "Old SBT launch jar should have been deleted" "[ -f ${BUILD_DIR}/.sbt_home/bin/sbt-launch-OLD.jar ]"
assertFileContains "SBT should have been installed" "Building app with sbt" "${STD_OUT}"
assertCaptured "SBT should have been installed" "Building app with sbt"
assertFileMD5 "fa57b75cbc45763b7188a71928f4cd9a" "${BUILD_DIR}/.sbt_home/bin/sbt-launch-${DEFAULT_SBT_VERSION}.jar"
assertFileMD5 "13edddc0e7a326a8bce014363270b6cc" "${BUILD_DIR}/.sbt_home/bin/sbt.boot.properties"
assertFileMD5 "7fef33ac6fc019bb361fa85c7dc07f7c" "${BUILD_DIR}/.sbt_home/.sbt/plugins/Heroku-${DEFAULT_SBT_VERSION}.scala"
assertFileMD5 "13cf615379347d6f1ef10a4334f578f7" "${BUILD_DIR}/.sbt_home/.sbt/plugins/heroku-plugins-${DEFAULT_SBT_VERSION}.sbt"
assertEquals "SBT script should have been copied from buildpack and replaced old version" "" "$(diff ${BUILDPACK_HOME}/opt/sbt-${DEFAULT_SBT_VERSION} ${BUILD_DIR}/.sbt_home/bin/sbt)"

# run
assertFileContains "SBT tasks to run should be output" "Running: sbt clean compile stage" "${STD_OUT}"
assertFileContains "SBT should run stage task" "${SBT_STAGING_STRING}" "${STD_OUT}"
assertCaptured "SBT tasks to run should be output" "Running: sbt clean compile stage"
assertCaptured "SBT should run stage task" "${SBT_STAGING_STRING}"

# clean up
assertEquals "Ivy2 cache should have been repacked" "" "$(diff -r ${BUILD_DIR}/.sbt_home/.ivy2 ${CACHE_DIR}/.sbt_home/.ivy2)"
assertEquals "SBT home should have been repacked" "" "$(diff -r ${BUILD_DIR}/.sbt_home/bin ${CACHE_DIR}/.sbt_home/bin)"

# re-deploy
compile

assertCapturedSuccess
assertFileNotContains "SBT should not be re-installed on re-run" "Building app with sbt" "${STD_OUT}"
assertFileContains "SBT tasks to run should still be outputed" "Running: sbt clean compile stage" "${STD_OUT}"
assertNotCaptured "SBT should not be re-installed on re-run" "Building app with sbt"
assertCaptured "SBT tasks to run should still be outputed" "Running: sbt clean compile stage"
}

testCompile_WithNonDefaultVersion()
Expand All @@ -129,8 +131,8 @@ testCompile_WithNonDefaultVersion()
compile

assertCapturedSuccess
assertFileContains "Default version of SBT should always be installed" "Building app with sbt v${DEFAULT_SBT_VERSION}" "${STD_OUT}"
assertFileContains "Specified SBT version should actually be used" "Getting org.scala-tools.sbt sbt_2.9.1 ${specifiedSbtVersion}" "${STD_OUT}"
assertCaptured "Default version of SBT should always be installed" "Building app with sbt v${DEFAULT_SBT_VERSION}"
assertCaptured "Specified SBT version should actually be used" "Getting org.scala-tools.sbt sbt_2.9.1 ${specifiedSbtVersion}"
}

testCompile_BuildFailure()
Expand All @@ -144,9 +146,7 @@ EOF

compile

assertEquals "1" "${RETURN}"
assertEquals "" "$(cat ${STD_ERR})"
assertFileContains "Failed to build app with SBT" "${STD_OUT}"
assertCapturedError "Failed to build app with SBT"
}

testCompile_NoStageTask()
Expand All @@ -156,24 +156,19 @@ testCompile_NoStageTask()

compile

assertEquals "1" "${RETURN}"
assertEquals "" "$(cat ${STD_ERR})"
assertFileContains "Not a valid key: stage" "${STD_OUT}"
assertFileContains "Failed to build app with SBT" "${STD_OUT}"
assertCapturedError "Not a valid key: stage"
assertCapturedError "Failed to build app with SBT"
}


testComplile_NoBuildPropertiesFile()
{
createSbtProject
rm ${BUILD_DIR}/project/build.properties

compile

assertEquals "1" "${RETURN}"
assertEquals "" "$(cat ${STD_ERR})"
assertFileContains "Error, your scala project must include project/build.properties and define sbt.version" "${STD_OUT}"
assertFileContains "You must use a release verison of sbt, sbt.version=${DEFAULT_SBT_VERSION} or greater" "${STD_OUT}"
assertCapturedError "Error, your scala project must include project/build.properties and define sbt.version"
assertCapturedError "You must use a release verison of sbt, sbt.version=${DEFAULT_SBT_VERSION} or greater"
}

testComplile_BuildPropertiesFileWithUnsupportedVersion()
Expand All @@ -182,10 +177,8 @@ testComplile_BuildPropertiesFileWithUnsupportedVersion()

compile

assertEquals "1" "${RETURN}"
assertEquals "" "$(cat ${STD_ERR})"
assertFileContains "Error, you have defined an unsupported sbt.version in project/build.properties" "${STD_OUT}"
assertFileContains "You must use a release verison of sbt, sbt.version=${DEFAULT_SBT_VERSION} or greater" "${STD_OUT}"
assertCapturedError "Error, you have defined an unsupported sbt.version in project/build.properties"
assertCapturedError "You must use a release verison of sbt, sbt.version=${DEFAULT_SBT_VERSION} or greater"
}

testComplile_BuildPropertiesFileWithUnsupportedVersion()
Expand All @@ -194,8 +187,6 @@ testComplile_BuildPropertiesFileWithUnsupportedVersion()

compile

assertEquals "1" "${RETURN}"
assertEquals "" "$(cat ${STD_ERR})"
assertFileContains "Error, you have defined an unsupported sbt.version in project/build.properties" "${STD_OUT}"
assertFileContains "You must use a release verison of sbt, sbt.version=${DEFAULT_SBT_VERSION} or greater" "${STD_OUT}"
assertCapturedError "Error, you have defined an unsupported sbt.version in project/build.properties"
assertCapturedError "You must use a release verison of sbt, sbt.version=${DEFAULT_SBT_VERSION} or greater"
}
5 changes: 5 additions & 0 deletions test/detect_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ testDetect_SbtFileFoundInRoot()
touch ${BUILD_DIR}/something.sbt

detect

assertAppDetected "Scala"
}

Expand All @@ -16,6 +17,7 @@ testDetect_ScalaFileFoundInProjectDir()
touch ${BUILD_DIR}/project/something.scala

detect

assertAppDetected "Scala"
}

Expand All @@ -25,6 +27,7 @@ testDetect_ScalaFileFoundInScalaDir()
touch ${BUILD_DIR}/.sbt/something.scala

detect

assertAppDetected "Scala"
}

Expand All @@ -34,11 +37,13 @@ testDetect_BuildPropertiesFileFoundInProjectDir()
touch ${BUILD_DIR}/project/build.properties

detect

assertAppDetected "Scala"
}

testDetect_NotFound()
{
detect

assertNoAppDetected
}
3 changes: 2 additions & 1 deletion test/release_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ addons:
EOF`
release
assertCapturedSuccess
assertEquals "${expected_release_output}" "$(cat ${STD_OUT})"
assertCaptured "${expected_release_output}"
}

0 comments on commit 36cfb1a

Please sign in to comment.