fix: address copilot review comments in integration test
- Quote all variables to prevent word-splitting/globbing issues - Use single-quoted trap for cleanup robustness - Remove unused output_dir variable - Add positive assertions for release2 and release3 in lint and diff tests
This commit is contained in:
parent
7a2cbeebb8
commit
4128650c0a
|
|
@ -5,10 +5,9 @@
|
|||
|
||||
test_case_dir="${cases_dir}/include-needs-transitive"
|
||||
input_dir="${test_case_dir}/input"
|
||||
output_dir="${test_case_dir}/output"
|
||||
|
||||
tmp_dir=$(mktemp -d)
|
||||
trap "rm -rf ${tmp_dir}" EXIT
|
||||
trap 'rm -rf "$tmp_dir"' EXIT
|
||||
|
||||
test_start "include-needs vs include-transitive-needs"
|
||||
|
||||
|
|
@ -17,24 +16,22 @@ info "https://github.com/helmfile/helmfile/issues/1003"
|
|||
# Test 1: --include-needs should only include direct dependencies
|
||||
info "Test 1: template with --include-needs should only include direct dependencies"
|
||||
template_output="${tmp_dir}/include-needs.log"
|
||||
${helmfile} -f ${input_dir}/helmfile.yaml -l name=release3 template --include-needs > ${template_output} 2>&1
|
||||
"${helmfile}" -f "${input_dir}/helmfile.yaml" -l name=release3 template --include-needs > "${template_output}" 2>&1
|
||||
code=$?
|
||||
if [ ${code} -ne 0 ]; then
|
||||
cat ${template_output}
|
||||
cat "${template_output}"
|
||||
fail "helmfile template with --include-needs should not fail"
|
||||
fi
|
||||
|
||||
# Should include release2 (direct dependency) and release3 (selected)
|
||||
# Should NOT include release1 (transitive dependency)
|
||||
if grep -q "release1" ${template_output}; then
|
||||
if grep -q "release1" "${template_output}"; then
|
||||
fail "--include-needs should NOT include transitive dependency release1"
|
||||
fi
|
||||
|
||||
if ! grep -q "release2" ${template_output}; then
|
||||
if ! grep -q "release2" "${template_output}"; then
|
||||
fail "--include-needs should include direct dependency release2"
|
||||
fi
|
||||
|
||||
if ! grep -q "release3" ${template_output}; then
|
||||
if ! grep -q "release3" "${template_output}"; then
|
||||
fail "--include-needs should include selected release release3"
|
||||
fi
|
||||
|
||||
|
|
@ -43,23 +40,22 @@ info "PASS: --include-needs only includes direct dependencies"
|
|||
# Test 2: --include-transitive-needs should include all dependencies
|
||||
info "Test 2: template with --include-transitive-needs should include all dependencies"
|
||||
template_output="${tmp_dir}/include-transitive-needs.log"
|
||||
${helmfile} -f ${input_dir}/helmfile.yaml -l name=release3 template --include-transitive-needs > ${template_output} 2>&1
|
||||
"${helmfile}" -f "${input_dir}/helmfile.yaml" -l name=release3 template --include-transitive-needs > "${template_output}" 2>&1
|
||||
code=$?
|
||||
if [ ${code} -ne 0 ]; then
|
||||
cat ${template_output}
|
||||
cat "${template_output}"
|
||||
fail "helmfile template with --include-transitive-needs should not fail"
|
||||
fi
|
||||
|
||||
# Should include all: release1, release2, and release3
|
||||
if ! grep -q "release1" ${template_output}; then
|
||||
if ! grep -q "release1" "${template_output}"; then
|
||||
fail "--include-transitive-needs should include transitive dependency release1"
|
||||
fi
|
||||
|
||||
if ! grep -q "release2" ${template_output}; then
|
||||
if ! grep -q "release2" "${template_output}"; then
|
||||
fail "--include-transitive-needs should include direct dependency release2"
|
||||
fi
|
||||
|
||||
if ! grep -q "release3" ${template_output}; then
|
||||
if ! grep -q "release3" "${template_output}"; then
|
||||
fail "--include-transitive-needs should include selected release release3"
|
||||
fi
|
||||
|
||||
|
|
@ -68,33 +64,49 @@ info "PASS: --include-transitive-needs includes all dependencies"
|
|||
# Test 3: Verify same behavior for lint command
|
||||
info "Test 3: lint with --include-needs should only include direct dependencies"
|
||||
lint_output="${tmp_dir}/lint-include-needs.log"
|
||||
${helmfile} -f ${input_dir}/helmfile.yaml -l name=release3 lint --include-needs > ${lint_output} 2>&1
|
||||
"${helmfile}" -f "${input_dir}/helmfile.yaml" -l name=release3 lint --include-needs > "${lint_output}" 2>&1
|
||||
code=$?
|
||||
if [ ${code} -ne 0 ]; then
|
||||
cat ${lint_output}
|
||||
cat "${lint_output}"
|
||||
fail "helmfile lint with --include-needs should not fail"
|
||||
fi
|
||||
|
||||
if grep -q "release1" ${lint_output}; then
|
||||
if grep -q "release1" "${lint_output}"; then
|
||||
fail "lint with --include-needs should NOT include transitive dependency release1"
|
||||
fi
|
||||
|
||||
if ! grep -q "release2" "${lint_output}"; then
|
||||
fail "lint with --include-needs should include direct dependency release2"
|
||||
fi
|
||||
|
||||
if ! grep -q "release3" "${lint_output}"; then
|
||||
fail "lint with --include-needs should include selected release release3"
|
||||
fi
|
||||
|
||||
info "PASS: lint with --include-needs only includes direct dependencies"
|
||||
|
||||
# Test 4: Verify same behavior for diff command
|
||||
info "Test 4: diff with --include-needs should only include direct dependencies"
|
||||
diff_output="${tmp_dir}/diff-include-needs.log"
|
||||
${helmfile} -f ${input_dir}/helmfile.yaml -l name=release3 diff --include-needs > ${diff_output} 2>&1
|
||||
"${helmfile}" -f "${input_dir}/helmfile.yaml" -l name=release3 diff --include-needs > "${diff_output}" 2>&1
|
||||
code=$?
|
||||
if [ ${code} -ne 0 ]; then
|
||||
cat ${diff_output}
|
||||
cat "${diff_output}"
|
||||
fail "helmfile diff with --include-needs should not fail"
|
||||
fi
|
||||
|
||||
if grep -q "release1" ${diff_output}; then
|
||||
if grep -q "release1" "${diff_output}"; then
|
||||
fail "diff with --include-needs should NOT include transitive dependency release1"
|
||||
fi
|
||||
|
||||
if ! grep -q "release2" "${diff_output}"; then
|
||||
fail "diff with --include-needs should include direct dependency release2"
|
||||
fi
|
||||
|
||||
if ! grep -q "release3" "${diff_output}"; then
|
||||
fail "diff with --include-needs should include selected release release3"
|
||||
fi
|
||||
|
||||
info "PASS: diff with --include-needs only includes direct dependencies"
|
||||
|
||||
test_pass "include-needs vs include-transitive-needs"
|
||||
|
|
|
|||
Loading…
Reference in New Issue