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>
109 lines
3.1 KiB
Bash
109 lines
3.1 KiB
Bash
#!/usr/bin/env bats
|
|
# Comprehensive unit tests for run.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}/run"
|
|
mkdir -p "${TEST_ROOT}"
|
|
export SCRIPT_DIR="${PROJECT_ROOT}"
|
|
|
|
# Create mock directories
|
|
export OUTPUT_DIR="${TEST_ROOT}/output"
|
|
export BUILD_DIR="${TEST_ROOT}/build"
|
|
mkdir -p "$OUTPUT_DIR" "$BUILD_DIR"
|
|
}
|
|
|
|
@test "run.sh exists and is executable" {
|
|
assert_file_exists "${PROJECT_ROOT}/run.sh"
|
|
assert [ -x "${PROJECT_ROOT}/run.sh" ]
|
|
}
|
|
|
|
@test "run.sh shows usage with help command" {
|
|
run bash "${PROJECT_ROOT}/run.sh" help
|
|
assert_success
|
|
assert_line --partial "Usage:"
|
|
assert_line --partial "build"
|
|
assert_line --partial "test"
|
|
assert_line --partial "lint"
|
|
assert_line --partial "clean"
|
|
assert_line --partial "shell"
|
|
assert_line --partial "iso"
|
|
assert_line --partial "test:iso"
|
|
}
|
|
|
|
@test "run.sh shows usage with no arguments" {
|
|
run bash "${PROJECT_ROOT}/run.sh"
|
|
assert_success
|
|
assert_line --partial "Usage:"
|
|
}
|
|
|
|
@test "run.sh creates output and build directories" {
|
|
local test_output="${TEST_ROOT}/new-output"
|
|
local test_build="${TEST_ROOT}/new-build"
|
|
|
|
# Mock directory creation
|
|
run bash -c "OUTPUT_DIR='$test_output' BUILD_DIR='$test_build' mkdir -p '$test_output' '$test_build'"
|
|
assert_success
|
|
assert [ -d "$test_output" ]
|
|
assert [ -d "$test_build" ]
|
|
}
|
|
|
|
@test "run.sh clean removes artifacts" {
|
|
# Create test artifacts
|
|
touch "${OUTPUT_DIR}/test.iso"
|
|
touch "${OUTPUT_DIR}/test.sha256"
|
|
touch "${BUILD_DIR}/test.log"
|
|
|
|
run bash -c "OUTPUT_DIR='$OUTPUT_DIR' BUILD_DIR='$BUILD_DIR' rm -rf '${OUTPUT_DIR:?}'/* '${BUILD_DIR:?}'/*"
|
|
assert_success
|
|
|
|
refute_file_exists "${OUTPUT_DIR}/test.iso"
|
|
refute_file_exists "${OUTPUT_DIR}/test.sha256"
|
|
refute_file_exists "${BUILD_DIR}/test.log"
|
|
}
|
|
|
|
@test "run.sh uses correct Docker image" {
|
|
assert_file_contains "${PROJECT_ROOT}/run.sh" "knel-football-dev:latest"
|
|
}
|
|
|
|
@test "run.sh sets correct environment variables" {
|
|
assert_file_contains "${PROJECT_ROOT}/run.sh" "TZ=America/Chicago"
|
|
assert_file_contains "${PROJECT_ROOT}/run.sh" "DEBIAN_FRONTEND=noninteractive"
|
|
assert_file_contains "${PROJECT_ROOT}/run.sh" "LC_ALL=C"
|
|
}
|
|
|
|
@test "run.sh ISO build uses privileged mode" {
|
|
assert_file_contains "${PROJECT_ROOT}/run.sh" "--privileged"
|
|
}
|
|
|
|
@test "run.sh ISO build uses root user" {
|
|
assert_file_contains "${PROJECT_ROOT}/run.sh" "--user root"
|
|
}
|
|
|
|
@test "run.sh test:iso delegates to test-iso.sh" {
|
|
assert_file_contains "${PROJECT_ROOT}/run.sh" "test-iso.sh"
|
|
}
|
|
|
|
@test "run.sh script is valid bash" {
|
|
run bash -n "${PROJECT_ROOT}/run.sh"
|
|
assert_success
|
|
}
|
|
|
|
@test "run.sh has all required commands documented" {
|
|
run bash "${PROJECT_ROOT}/run.sh" help
|
|
assert_line --partial "build"
|
|
assert_line --partial "test"
|
|
assert_line --partial "test:iso"
|
|
assert_line --partial "lint"
|
|
assert_line --partial "clean"
|
|
assert_line --partial "shell"
|
|
assert_line --partial "iso"
|
|
assert_line --partial "help"
|
|
}
|