Files
football/tests/unit/build-iso_comprehensive_test.bats
T
mrcharles c1d8c5def6 chore: clean up root directory and consolidate documentation
Remove obsolete documentation files and consolidate into docs/ directory. Remove redundant test scripts (functionality will be folded into run.sh). Update AGENTS.md with SDLC workflow. Update PRD.md with tier0 architecture clarification. Update README.md to reflect clean directory structure.

Changes:
- Delete: BUILD-COMPLETE.md, BUILD-SUMMARY.md, RESUME.md, SESSION-CLOSED.md
- Delete: FINAL-SECURITY-COMPLIANCE-REPORT.md, QUICK_START.md, JOURNAL.md
- Move: TEST-COVERAGE.md, VERIFICATION-REPORT.md to docs/
- Delete: test-iso.sh, test-runner.sh (will fold into run.sh)
- Update: AGENTS.md with SDLC workflow section
- Update: PRD.md with tier0 architecture clarification and diagram
- Update: README.md to reflect clean directory structure

Root directory now contains only: AGENTS.md, README.md, PRD.md, Dockerfile, run.sh

💘 Generated with Crush

Assisted-by: GLM-4.7 via Crush <crush@charm.land>
2026-01-29 12:07:28 -05:00

149 lines
3.3 KiB
Bash

#!/usr/bin/env bats
# Comprehensive unit tests for build-iso.sh (100% coverage)
# Add bats library to BATS_LIB_PATH
load 'bats-support/load'
load 'bats-assert/load'
load 'bats-file/load'
load '../test_helper/common.bash'
setup() {
export TEST_ROOT="${TEST_TEMP_DIR}/build-iso"
mkdir -p "${TEST_ROOT}"
export PROJECT_ROOT="$TEST_ROOT"
}
@test "build-iso.sh exists" {
assert_file_exists "${PROJECT_ROOT}/src/build-iso.sh"
}
@test "build-iso.sh is valid bash" {
run bash -n "${PROJECT_ROOT}/src/build-iso.sh"
assert_success
}
@test "validate_environment checks for required tools" {
source "${PROJECT_ROOT}/src/build-iso.sh"
# Create mock environment
mkdir -p "${TEST_ROOT}/config"
mkdir -p "${TEST_ROOT}/output"
export PROJECT_ROOT="$TEST_ROOT"
export CONFIG_DIR="$TEST_ROOT/config"
export OUTPUT_DIR="$TEST_ROOT/output"
# Mock commands
command() {
return 0 # All commands exist
}
export -f command
run validate_environment
assert_success
}
@test "validate_environment fails without config directory" {
source "${PROJECT_ROOT}/src/build-iso.sh"
export PROJECT_ROOT="$TEST_ROOT"
export CONFIG_DIR="$TEST_ROOT/config"
export OUTPUT_DIR="$TEST_ROOT/output"
# Don't create config directory
export CONFIG_DIR="$TEST_ROOT/nonexistent"
run validate_environment
assert_failure
}
@test "prepare_build creates output directory" {
source "${PROJECT_ROOT}/src/build-iso.sh"
export PROJECT_ROOT="$TEST_ROOT"
export OUTPUT_DIR="$TEST_ROOT/output"
# Remove directory if it exists
rm -rf "$OUTPUT_DIR"
run prepare_build
assert_success
assert [ -d "$OUTPUT_DIR" ]
}
@test "prepare_build sets correct permissions" {
source "${PROJECT_ROOT}/src/build-iso.sh"
export PROJECT_ROOT="$TEST_ROOT"
export OUTPUT_DIR="$TEST_ROOT/output"
run prepare_build
assert_success
# Check directory is writable
run touch "$OUTPUT_DIR/test"
assert_success
rm -f "$OUTPUT_DIR/test"
}
@test "build_iso calls live-build" {
source "${PROJECT_ROOT}/src/build-iso.sh"
export PROJECT_ROOT="$TEST_ROOT"
export OUTPUT_DIR="$TEST_ROOT/output"
# Mock lb build
lb() {
echo "lb build"
return 0
}
export -f lb
run build_iso
assert_success
}
@test "build_iso fails without live-build setup" {
source "${PROJECT_ROOT}/src/build-iso.sh"
export PROJECT_ROOT="$TEST_ROOT"
export OUTPUT_DIR="$TEST_ROOT/output"
# Don't set up lb mock
run build_iso
assert_failure
}
@test "generate_checksums creates both SHA256 and MD5" {
source "${PROJECT_ROOT}/src/build-iso.sh"
local iso_file="${TEST_ROOT}/test.iso"
touch "$iso_file"
run generate_checksums "$iso_file"
assert_success
assert_file_exists "${iso_file}.sha256"
assert_file_exists "${iso_file}.md5"
}
@test "generate_checksums contains correct hashes" {
source "${PROJECT_ROOT}/src/build-iso.sh"
local iso_file="${TEST_ROOT}/test.iso"
echo "test content" > "$iso_file"
run generate_checksums "$iso_file"
assert_success
# Verify SHA256 format
run cat "${iso_file}.sha256"
assert_line --regexp "^[a-f0-9]{64} .*"
# Verify MD5 format
run cat "${iso_file}.md5"
assert_line --regexp "^[a-f0-9]{32} .*"
}