test(example): layered SQLite API sample app (ports & adapters) - #20
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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
force-pushed
the
examples/testdata-sample
branch
from
August 18, 2026 11:44
d976d33 to
15b94d6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A self-contained sample project under
testdata/example(its own module, joined to the root viago.work) that uses bisql the way a real service would: a small HTTP API executing its templates against an in-memory SQLite database (pure-Gomodernc.org/sqlite), laid out in clean-architecture layers with manual DI.app/query,app/schema) are the abstractions;app/infrastructure/*implements them;cmd/servewires them by hand.presentation_test.godrives the whole stack over a real:memory:DB, proving the bisql-built SQL is valid SQLite.testdata/snapshots/:<name>.expanded.sqland<name>.<case>.embedded.sql, regenerated withgo test ./... -update.samber/lostyle (helpers/loops minimized).🤖 Generated with Claude Code