#!/usr/bin/env bash

#
# Create a Heroku app with the following buildpack:
# https://github.com/ddollar/buildpack-tet
#
# Push this Python buildpack to that Heroku app to
# run the tests.
#

testDetectWithReqs() {
  detect "simple-requirements"
  assertCapturedEquals "Python"
  assertCapturedSuccess
}

testDetectWithEmptyReqs() {
  detect "empty-requirements"
  assertCapturedEquals "Python"
  assertCapturedSuccess
}

testDetectDjango14() {
  detect "django-1.4-skeleton"
  assertCapturedEquals "Python/Django"
  assertCapturedSuccess
}

testDetectDjango13() {
  detect "django-1.3-skeleton"
  assertCapturedEquals "Python/Django"
  assertCapturedSuccess
}

testDetectNotDjangoWithSettings() {
  detect "not-django"
  assertCapturedEquals "Python"
  assertCapturedSuccess
}

testDetectWithSetupPy() {
  detect "distutils"
  assertCapturedEquals "Python"
  assertCapturedSuccess
}

testDetectWithSetupRequires() {
  detect "no-requirements"
  assertCapturedEquals "Python"
  assertCapturedSuccess
}

testDetectNotPython() {
  detect "not-python"
  assertNotCaptured "Python"
  assertNoAppDetected
}

# testPackageJsonWithVersion() {
#   compile "package-json-version"
#   assertCaptured "Using Node.js version: 0.6.11"
#   assertCaptured "Using npm version: 1.1.9"
#   assertCapturedSuccess
# }

# testPackageJsonWithoutVersion() {
#   compile "package-json-noversion"
#   assertCaptured "Using Node.js version: 0.4.7"
#   assertCaptured "Using npm version: 1.0.106"
#   assertCapturedSuccess
# }

## utils ########################################

pushd $(dirname 0) >/dev/null
BASE=$(pwd)
popd >/dev/null

source ${BASE}/vendor/test-utils

detect() {
  capture ${BASE}/bin/detect ${BASE}/test/$1
}

compile() {
  capture ${BASE}/bin/compile ${BASE}/test/$1
}

source ${BASE}/vendor/shunit2
 
