diff options
| author | Tranch <tranch.xiao@gmail.com> | 2026-08-26 11:20:16 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-26 11:20:16 +0800 |
| commit | 65906b9536aaebdec4169b40e7b9eb86b73e65fe (patch) | |
| tree | 56dfe91e98326a18363f1f4781cf001a6200e187 /tests | |
| parent | c7a47b2ba1cfc17348e729c1b7a6689bd5c9c95d (diff) | |
| parent | 890d6cd86b6bc83b7960c5f54a526af2c13cb755 (diff) | |
| download | AeroCore-OS-65906b9536aaebdec4169b40e7b9eb86b73e65fe.tar.gz AeroCore-OS-65906b9536aaebdec4169b40e7b9eb86b73e65fe.zip | |
Merge pull request #21 from AeroCore-IO/fix/dotenv-overrides
fix(config): make local dotenv optional
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test-dotenv-precedence.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test-dotenv-precedence.sh b/tests/test-dotenv-precedence.sh new file mode 100755 index 0000000..f2cc760 --- /dev/null +++ b/tests/test-dotenv-precedence.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -euo pipefail + +project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +tmp_dir="$(mktemp -d)" +trap 'rm -rf "${tmp_dir}"' EXIT + +grep -Fqx 'set dotenv-filename := ".env"' "${project_root}/Justfile" +grep -Fqx '.env' "${project_root}/.gitignore" +if rg -F -- '--dotenv-path image-template.env' "${project_root}/.github/workflows"; then + echo 'CI must not load image-template.env as a dotenv file' >&2 + exit 1 +fi + +printf '%s\n' \ + 'set dotenv-load' \ + 'value := env_var("VALUE")' \ + 'show:' \ + ' @echo "{{value}}"' > "${tmp_dir}/justfile" +printf '%s\n' 'VALUE=from-dotenv' > "${tmp_dir}/.env" + +[[ "$(cd "${tmp_dir}" && just show)" == 'from-dotenv' ]] +[[ "$(cd "${tmp_dir}" && VALUE=from-runtime just show)" == 'from-runtime' ]] + +mkdir "${tmp_dir}/without-dotenv" +cp "${tmp_dir}/justfile" "${tmp_dir}/without-dotenv/justfile" +[[ "$(cd "${tmp_dir}/without-dotenv" && VALUE=from-runtime just show)" == 'from-runtime' ]] |
