forked from rfay/ddev-php-patch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.bats
57 lines (50 loc) · 1.61 KB
/
test.bats
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
setup() {
set -eu -o pipefail
TEST_BREW_PREFIX="$(brew --prefix)"
load "${TEST_BREW_PREFIX}/lib/bats-support/load.bash"
load "${TEST_BREW_PREFIX}/lib/bats-assert/load.bash"
export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.."
export TESTDIR=~/tmp/ddev-php-patch-build-test
mkdir -p $TESTDIR
export PROJNAME=test-php-patch-build
export DDEV_NON_INTERACTIVE=true
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true
cd "${TESTDIR}"
ddev config --project-name=${PROJNAME} --fail-on-hook-fail
ddev start -y
export STATIC_PHP_VERSION="8.2.8"
cat <<EOF >index.php
<?php
echo phpversion();
EOF
}
health_checks() {
run ddev php --version
assert_success
assert_output --partial "PHP ${STATIC_PHP_VERSION}"
run curl --fail -s https://${PROJNAME}.ddev.site/
assert_success
assert_output --partial "${STATIC_PHP_VERSION}"
}
teardown() {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1
[ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR}
}
@test "install from directory" {
set -eu -o pipefail
cd ${TESTDIR}
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
echo ${STATIC_PHP_VERSION} | ddev get ${DIR}
ddev restart >/dev/null
health_checks
}
@test "install from release" {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
echo "# ddev get ddev/ddev-php-patch-build with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
echo ${STATIC_PHP_VERSION} | ddev get ${DIR}
ddev restart >/dev/null
health_checks
}