# Tests for archeflow-init.sh — project initialization from templates. # # Validates: usage output, --list, --from (clone), and argument parsing. setup() { load test_helper _common_setup } teardown() { _common_teardown } @test "init: shows usage when called with no args" { run "$LIB_DIR/archeflow-init.sh" [ "$status" -eq 0 ] [[ "$output" == *"Usage"* ]] [[ "$output" == *"bundle-name"* ]] } @test "init: --list shows template listing without errors" { run "$LIB_DIR/archeflow-init.sh" --list [ "$status" -eq 0 ] [[ "$output" == *"Templates"* ]] [[ "$output" == *"Bundles"* ]] } @test "init: --from fails when source has no .archeflow dir" { local source_dir source_dir=$(mktemp -d) run "$LIB_DIR/archeflow-init.sh" --from "$source_dir" [ "$status" -ne 0 ] [[ "$output" == *"No .archeflow/"* ]] rm -rf "$source_dir" } @test "init: --from clones setup from another project" { # Create a source project with .archeflow structure local source_dir source_dir=$(mktemp -d) mkdir -p "$source_dir/.archeflow/teams" "$source_dir/.archeflow/workflows" echo "name: test-team" > "$source_dir/.archeflow/teams/test.yaml" echo "name: test-workflow" > "$source_dir/.archeflow/workflows/test.yaml" echo "bundle: test" > "$source_dir/.archeflow/config.yaml" run "$LIB_DIR/archeflow-init.sh" --from "$source_dir" [ "$status" -eq 0 ] [ -f ".archeflow/teams/test.yaml" ] [ -f ".archeflow/workflows/test.yaml" ] [ -f ".archeflow/config.yaml" ] rm -rf "$source_dir" } @test "init: --from skips events and artifacts directories" { local source_dir source_dir=$(mktemp -d) mkdir -p "$source_dir/.archeflow/events" "$source_dir/.archeflow/artifacts" mkdir -p "$source_dir/.archeflow/teams" echo "name: test" > "$source_dir/.archeflow/teams/t.yaml" echo '{"test":true}' > "$source_dir/.archeflow/events/run.jsonl" echo "artifact" > "$source_dir/.archeflow/artifacts/test.txt" run "$LIB_DIR/archeflow-init.sh" --from "$source_dir" [ "$status" -eq 0 ] [ ! -f ".archeflow/events/run.jsonl" ] [ ! -f ".archeflow/artifacts/test.txt" ] [[ "$output" == *"skipped events"* ]] rm -rf "$source_dir" } @test "init: rejects unknown options" { run "$LIB_DIR/archeflow-init.sh" --nonexistent [ "$status" -ne 0 ] [[ "$output" == *"Unknown option"* ]] } @test "init: --save fails with no .archeflow directory" { run "$LIB_DIR/archeflow-init.sh" --save test-save [ "$status" -ne 0 ] [[ "$output" == *"No .archeflow/"* ]] }