Skip to content

Add framework-level tests for all bash scripts #25

@PAMulligan

Description

@PAMulligan

Description

Create a test suite for Nerva's 9 automation scripts using a bash testing framework like BATS (Bash Automated Testing System). The scripts are production tooling — they deserve the same testing rigor as the APIs they generate.

Why

The scripts are the primary interface for users interacting with Nerva. A bug in `setup-project.sh` could generate broken projects. Currently, CI validates syntax (`bash -n`) but doesn't test behavior. Script tests catch regressions when contributors modify the scripts.

Acceptance Criteria

  • Add `bats-core` as a test dependency (or equivalent bash testing framework)
  • Create `tests/scripts/` directory
  • Write tests for at least:
    • `setup-project.sh`: Correct directory structure, file generation, platform flags
    • `run-tests.sh`: Flag parsing, error handling
    • `check-types.sh`: Flag parsing, exit codes
    • `security-scan.sh`: Pattern detection works correctly
  • Add a CI step to run script tests
  • Document how to run script tests locally
  • CI passes

Implementation Notes

Using BATS:
```bash

tests/scripts/setup-project.bats

@test "setup-project creates correct directory structure" {
run ./scripts/setup-project.sh test-project --node --dry-run
[ "$status" -eq 0 ]
[[ "$output" == "api/src/routes" ]]
}

@test "setup-project rejects missing project name" {
run ./scripts/setup-project.sh
[ "$status" -eq 1 ]
[[ "$output" == "Missing project name" ]]
}
```

Depends on #8 (`--dry-run` flag) for safe testing without side effects.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions