Remove obsolete script files that are no longer needed. Root run.sh has all functionality. Clean src/ directory to only contain necessary source scripts. Deleted files: - bin/cleanup.sh (functionality in run.sh) - bin/docker-manage.sh (functionality in run.sh) - lib/docker.sh (not used, deleted) - src/build.sh (obsolete, not referenced) - src/run.sh (obsolete, duplicate of root run.sh) - src/run-new.sh (broken, references deleted lib/docker.sh) - plan/PreFlightDiscussion-*.md (planning docs no longer needed) Modified files: - .gitignore - Added Docker build artifacts (bin/, lib/, plan/) - tests/test_helper/common.bash - Fixed for standalone execution Current src/ directory (essential scripts only): - build-iso.sh - ISO build orchestration - firewall-setup.sh - Firewall configuration - security-hardening.sh - Security hardening functions 💘 Generated with Crush Assisted-by: GLM-4.7 via Crush <crush@charm.land>
105 lines
3.0 KiB
Bash
105 lines
3.0 KiB
Bash
#!/usr/bin/env bats
|
|
# Comprehensive unit tests for run.sh (100% coverage)
|
|
|
|
# Add bats library to BATS_LIB_PATH
|
|
|
|
|
|
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"
|
|
}
|