# Testing

## Automated layers

- Module tests exercise bounded reads, header fields, page layout, four B-tree
  types, record values, overflow, freelist, WAL, snapshots, checker behavior,
  and text/JSON reports.
- A separate package smoke test verifies the public library can be imported.
- The fixture generator creates normal, WAL, invalid-magic, and truncated files
  with Python's standard SQLite library.
- GitHub Actions runs format, static check, build, all MoonBit tests, fixture
  generation, and the four native CLI commands for pushes and pull requests.

## Local verification

Run:

~~~bash
moon fmt --check
moon check --deny-warn
moon build --deny-warn
moon build --target native --deny-warn
moon test --deny-warn
python3 scripts/generate_fixtures.py
~~~

Then exercise the CLI:

~~~bash
moon run --target native cmd/pagelens -- inspect fixtures/generated/sample.db
moon run --target native cmd/pagelens -- wal fixtures/generated/snapshot.db-wal
moon run --target native cmd/pagelens -- snapshot fixtures/generated/snapshot.db
moon run --target native cmd/pagelens -- check fixtures/generated/sample.db
~~~

## Fixture provenance

Every value in the fixtures is declared in scripts/generate_fixtures.py. The
binary outputs are ignored, reproducible, and not copied from a third-party
dataset. Synthetic MoonBit tests similarly construct their bytes in the test
source.

## Failure policy

A failing test is fixed in parser or fixture logic. Core validations are not
disabled to make CI green. Corruption tests assert explicit ParseError variants
or diagnostic codes so a regression cannot silently turn a failure into a
successful parse.
