Files
cozystack/hack/installer-image-packages-push_test.bats
Myasnikov Daniil cc942fed68 test(tests): run unit suites with Bats and retain POSIX coverage
The shell translator rewrites test bodies and loses Bats reporting.
The unit lane needs complete TAP results and JUnit reports without
changing how live-cluster suites run.

Sourced production helpers still need a dash pass, and unit test bodies
need nounset without exporting shell options into subprocesses.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-10-07 11:04:00 +03:00

29 lines
1.5 KiB
Bash

#!/usr/bin/env bats
# `make image-packages` in packages/core/installer publishes the packages
# artifact with `flux push artifact` and then stamps the pushed digest into
# values.yaml as platformSourceRef. The operator hands that ref to Flux, which
# pulls the artifact by digest from the registry, so a build that pushes nothing
# must leave the committed ref alone rather than stamp one that resolves nowhere.
#
# Run with: bats hack/installer-image-packages-push_test.bats. The bodies avoid
# run/$status/$output so the legacy hack/cozytest.sh translator can still run
# them, and a `!`-negated pipeline is suppressed under set -e, so negative checks
# use the `if grep -q ...; then ...; false; fi` idiom.
load test_helper
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
@test "image-packages pushes nothing and stamps nothing with PUSH=0" {
out=$(env -u PUSH -u LOAD make --dry-run -C "$REPO_ROOT/packages/core/installer" image-packages PUSH=0)
if echo "$out" | grep -q 'flux push artifact'; then echo "FAIL: PUSH=0 still pushes the packages artifact"; false; fi
if echo "$out" | grep -q 'platformSourceRef = '; then echo "FAIL: PUSH=0 still stamps platformSourceRef"; false; fi
}
@test "image-packages pushes and stamps the digest when PUSH is left at its default" {
out=$(env -u PUSH -u LOAD make --dry-run -C "$REPO_ROOT/packages/core/installer" image-packages)
echo "$out" | grep -q 'flux push artifact'
echo "$out" | grep -q "platformSourceUrl = strenv(REPO)"
echo "$out" | grep -q 'platformSourceRef = "digest=" + strenv(DIGEST)'
}