Skip to content

test: cover the codegen CLI, introspect and the untested render paths - #29

Draft
TomChv wants to merge 1 commit into
feat/packager-staleness-checkfrom
feat/codegen-test-coverage
Draft

test: cover the codegen CLI, introspect and the untested render paths#29
TomChv wants to merge 1 commit into
feat/packager-staleness-checkfrom
feat/codegen-test-coverage

Conversation

@TomChv

@TomChv TomChv commented Aug 12, 2026

Copy link
Copy Markdown
Member

Coverage was lopsided: the generator sat at 75% while the CLI this stack was
built around was at 0% for every subcommand, and three entrypoint render paths
had never executed. 56.3% overall, but not where a regression would hurt.

The real hole was enums and interfaces. The entrypoint golden happened to use
neither, so renderEnumDef, renderEnumMemberCall, renderInterfaceDef and
sortedEnumValueKeys had never run — for constructs modules use routinely.
Rather than hand-write typedef JSON, the fixture module grew an @EnumType, an
interface and a variadic and was rescanned with the real introspector, so the
golden still pins the renderer against input it actually receives.

The CLI tests cover dispatch and each required-flag error, and run each
generator into a temp dir, which also exercises the overlay that writes results
to disk. Introspect gets an httptest session: the token goes out as basic auth,
only the payload under "data" is written, and a GraphQL errors array fails
loudly rather than writing an empty schema — which would otherwise surface much
later as bindings with no API in them.

The routing check asserts what is otherwise invisible: both paths emit the same
file names, so the bundle each module ends up with is the only evidence of
which generator ran. Confirmed it fails when the condition is flipped.

Coverage is now 70.6%, with the CLI at 80-90% per subcommand.

Signed-off-by: Tom Chauveau tom@dagger.io


Stack created with GitHub Stacks CLIGive Feedback 💬

Coverage was lopsided: the generator sat at 75% while the CLI this stack was
built around was at 0% for every subcommand, and three entrypoint render paths
had never executed. 56.3% overall, but not where a regression would hurt.

The real hole was enums and interfaces. The entrypoint golden happened to use
neither, so renderEnumDef, renderEnumMemberCall, renderInterfaceDef and
sortedEnumValueKeys had never run — for constructs modules use routinely.
Rather than hand-write typedef JSON, the fixture module grew an @EnumType, an
interface and a variadic and was rescanned with the real introspector, so the
golden still pins the renderer against input it actually receives.

The CLI tests cover dispatch and each required-flag error, and run each
generator into a temp dir, which also exercises the overlay that writes results
to disk. Introspect gets an httptest session: the token goes out as basic auth,
only the payload under "data" is written, and a GraphQL errors array fails
loudly rather than writing an empty schema — which would otherwise surface much
later as bindings with no API in them.

The routing check asserts what is otherwise invisible: both paths emit the same
file names, so the bundle each module ends up with is the only evidence of
which generator ran. Confirmed it fails when the condition is flipped.

Coverage is now 70.6%, with the CLI at 80-90% per subcommand.

Signed-off-by: Tom Chauveau <tom@dagger.io>
@TomChv
TomChv force-pushed the feat/codegen-test-coverage branch from f8d5ebb to 7f9fc67 Compare August 12, 2026 13:57
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