mirror of
https://github.com/dokku/dokku.git
synced 2026-02-24 04:00:36 +01:00
tests: add test for builder-pack:set projectoml-path
This commit is contained in:
15
tests/apps/python/cnb/1/bin/build
Executable file
15
tests/apps/python/cnb/1/bin/build
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
layers_dir=$1
|
||||
|
||||
echo "Building with buildpack 1"
|
||||
bp_layer=$layers_dir/1
|
||||
bp_env_dir=$bp_layer/env
|
||||
mkdir -p $bp_env_dir
|
||||
|
||||
echo "TESTENV_1" > $bp_env_dir/TESTENV
|
||||
|
||||
echo "[types]" > ${bp_layer}.toml
|
||||
echo "launch = true" >> ${bp_layer}.toml
|
||||
echo "build = true" >> ${bp_layer}.toml
|
||||
echo "cache = true" >> ${bp_layer}.toml
|
||||
3
tests/apps/python/cnb/1/bin/detect
Executable file
3
tests/apps/python/cnb/1/bin/detect
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "1" && exit 0
|
||||
9
tests/apps/python/cnb/1/buildpack.toml
Normal file
9
tests/apps/python/cnb/1/buildpack.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
api = "0.6"
|
||||
|
||||
[buildpack]
|
||||
id = "1"
|
||||
version = "0.1.0"
|
||||
name = "1 Packages Buildpack"
|
||||
|
||||
[[stacks]]
|
||||
id = "heroku-20"
|
||||
21
tests/apps/python/cnb/2/bin/build
Executable file
21
tests/apps/python/cnb/2/bin/build
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
layers_dir=$1
|
||||
|
||||
echo "Building with buildpack 2"
|
||||
bp_layer=$layers_dir/2
|
||||
bp_env_dir=$bp_layer/env
|
||||
mkdir -p $bp_env_dir
|
||||
|
||||
export TESTENV="$TESTENV:anotherenv"
|
||||
|
||||
echo "===> env start"
|
||||
env
|
||||
echo "===> env end"
|
||||
|
||||
echo "TESTENV_2" > $bp_env_dir/TESTENV
|
||||
|
||||
echo "[types]" > ${bp_layer}.toml
|
||||
echo "launch = true" >> ${bp_layer}.toml
|
||||
echo "build = true" >> ${bp_layer}.toml
|
||||
echo "cache = true" >> ${bp_layer}.toml
|
||||
3
tests/apps/python/cnb/2/bin/detect
Executable file
3
tests/apps/python/cnb/2/bin/detect
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "2" && exit 0
|
||||
9
tests/apps/python/cnb/2/buildpack.toml
Normal file
9
tests/apps/python/cnb/2/buildpack.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
api = "0.6"
|
||||
|
||||
[buildpack]
|
||||
id = "2"
|
||||
version = "0.1.0"
|
||||
name = "2 Packages Buildpack"
|
||||
|
||||
[[stacks]]
|
||||
id = "heroku-20"
|
||||
10
tests/apps/python/project2.toml
Normal file
10
tests/apps/python/project2.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[project]
|
||||
id = "python"
|
||||
name = "python"
|
||||
version = "1.0.0"
|
||||
|
||||
[[build.buildpacks]]
|
||||
uri = "./cnb/1"
|
||||
|
||||
[[build.buildpacks]]
|
||||
uri = "./cnb/1"
|
||||
81
tests/unit/builder-pack.bats
Normal file
81
tests/unit/builder-pack.bats
Normal file
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
setup_file() {
|
||||
if ! command -v "pack" &>/dev/null; then
|
||||
add-apt-repository --yes ppa:cncf-buildpacks/pack-cli
|
||||
apt-get update
|
||||
apt-get --yes install pack-cli
|
||||
fi
|
||||
}
|
||||
|
||||
setup() {
|
||||
create_app
|
||||
}
|
||||
|
||||
teardown() {
|
||||
destroy_app
|
||||
}
|
||||
|
||||
@test "(builder-pack:set)" {
|
||||
run /bin/bash -c "dokku builder:set $TEST_APP selected pack"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku buildpacks:set-property $TEST_APP stack heroku/buildpacks:20"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run deploy_app python dokku@dokku.me:$TEST_APP inject_requirements_txt
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains 'Building with buildpack 1' 0
|
||||
assert_output_contains 'Installing requirements with pip'
|
||||
|
||||
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path nonexistent.toml"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains 'Building with buildpack 1' 0
|
||||
assert_output_contains 'Installing requirements with pip'
|
||||
|
||||
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path project2.toml"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains 'Building with buildpack 1'
|
||||
assert_output_contains 'Installing requirements with pip' 0
|
||||
|
||||
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains 'Building with buildpack 1' 0
|
||||
assert_output_contains 'Installing requirements with pip'
|
||||
}
|
||||
|
||||
inject_requirements_txt() {
|
||||
local APP="$1"
|
||||
local APP_REPO_DIR="$2"
|
||||
[[ -z "$APP" ]] && local APP="$TEST_APP"
|
||||
echo "flask" >>"$APP_REPO_DIR/requirements.txt"
|
||||
}
|
||||
Reference in New Issue
Block a user