Skip to content

test(example): layered SQLite API sample app (ports & adapters) - #20

Merged
mpyw merged 1 commit into
mainfrom
examples/testdata-sample
Aug 18, 2026
Merged

test(example): layered SQLite API sample app (ports & adapters)#20
mpyw merged 1 commit into
mainfrom
examples/testdata-sample

Conversation

@mpyw

@mpyw mpyw commented Aug 18, 2026

Copy link
Copy Markdown
Owner

A self-contained sample project under testdata/example (its own module, joined to the root via go.work) that uses bisql the way a real service would: a small HTTP API executing its templates against an in-memory SQLite database (pure-Go modernc.org/sqlite), laid out in clean-architecture layers with manual DI.

src/app/app.go                 application core: struct App aggregates the query ports
src/app/query/                 query ports (one interface per query) + DTOs
src/app/schema/                the Migrator port
src/app/presentation/          HTTP delivery; depends only on *app.App (+ end-to-end test)
src/app/infrastructure/query/  query impl (bisql + database/sql), one file per query;
                               .sql templates under sql/ (embedded); snapshot test + testdata
src/app/infrastructure/schema/ Migrator impl + schema.sql
src/cmd/serve/                 composition root (manual DI wiring)
  • Interfaces (app/query, app/schema) are the abstractions; app/infrastructure/* implements them; cmd/serve wires them by hand.
  • The queries exercise the full feature set with correct anchoring; presentation_test.go drives the whole stack over a real :memory: DB, proving the bisql-built SQL is valid SQLite.
  • Two snapshot kinds per query under testdata/snapshots/: <name>.expanded.sql and <name>.<case>.embedded.sql, regenerated with go test ./... -update.
  • The example code is written in samber/lo style (helpers/loops minimized).
  • Added to the example module only; the root module is unaffected.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.52%. Comparing base (f3f5c4d) to head (15b94d6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #20   +/-   ##
=======================================
  Coverage   96.52%   96.52%           
=======================================
  Files          11       11           
  Lines         951      951           
=======================================
  Hits          918      918           
  Misses         21       21           
  Partials       12       12           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A self-contained sample project under testdata/example (its own module, joined
to the root via go.work) that uses bisql the way a real service would: a small
HTTP API executing its templates against an in-memory SQLite database (pure-Go
modernc.org/sqlite), laid out in clean-architecture layers with manual DI.

  src/app/app.go                 application core: struct App aggregates the query ports
  src/app/query/                 query ports (one interface per query) + DTOs
  src/app/schema/                the Migrator port
  src/app/presentation/          HTTP delivery; depends only on *app.App (+ end-to-end test)
  src/app/infrastructure/query/  query impl (bisql + database/sql), one file per query;
                                 .sql templates under sql/ (embedded); snapshot test + testdata
  src/app/infrastructure/schema/ Migrator impl + schema.sql
  src/cmd/serve/                 composition root (manual DI wiring)

Interfaces (app/query, app/schema) are the abstractions; app/infrastructure/*
implements them; cmd/serve wires them by hand. presentation_test.go drives the
whole stack over a real :memory: DB, proving the bisql-built SQL is valid SQLite.
Two snapshot kinds per query under testdata/snapshots/: <name>.expanded.sql and
<name>.<case>.embedded.sql (go test ./... -update). The example code is written
in samber/lo style. go work sync aligns the shared golang.org/x/sync indirect;
the root library is otherwise unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YAydPGeSHjZvJv22oz4P6d
@mpyw
mpyw force-pushed the examples/testdata-sample branch from d976d33 to 15b94d6 Compare August 18, 2026 11:44
@mpyw
mpyw merged commit 3cc7fa8 into main Aug 18, 2026
3 checks passed
@mpyw
mpyw deleted the examples/testdata-sample branch August 19, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant