Skip to content

test(appgen): cover generated-app module loud-failure path#351

Merged
cssbruno merged 1 commit into
mainfrom
worktree-fail-loudly-gaps
Jun 13, 2026
Merged

test(appgen): cover generated-app module loud-failure path#351
cssbruno merged 1 commit into
mainfrom
worktree-fail-loudly-gaps

Conversation

@cssbruno

Copy link
Copy Markdown
Owner

What

Closes the one concrete gap left after PR #350 (the fail-loudly fallback hardening, now merged): the moduleSource loud-failure path had no test. Only the decision heuristic (isLocalModuleImportPath / appHasLocalModuleImports) was unit-tested; the actual error propagation was unverified.

Changes

Two integration tests in internal/appgen/appgen_test.go. Both run outside any Go module via t.Chdir(t.TempDir()), so go list -m -json fails with a genuine "no go.mod" reason:

  • TestModuleSourceFailsLoudlyWhenAppModuleUndeterminedWithLocalImports — with an app-owned inline go {} import, moduleSource surfaces cannot determine the app Go module instead of silently dropping the require/replace.
  • TestModuleSourceToleratesUndeterminedAppModuleWithoutLocalImports — with no app-owned imports, the same go list -m failure is tolerated and a valid generated go.mod is still produced.

This pins down both sides of the intentional behavior so neither can regress silently.

Verification

  • go test ./... across all 55 non-example packages passes (full suite, not just touched packages — closing the earlier "full suite not run" gap).
  • examples/* fail to go build as before — they are .gwdk demo projects, not Go mains; pre-existing and unrelated.

Deferred items — evaluated, not bugs

While here I re-checked the two "judgment call" items from the gap review and confirmed neither is masked error-handling:

  • build-data {name} precedence (data wins over route param for a bare name): documented precedence with explicit param("x") / field("x") overrides; both values are valid. Not a masked error — a hard error would break valid usage.
  • layout/component scope-shadowing (same-package shadows global): standard scoping semantics. Unresolved / cross-package cases already fail loudly (validate_identity, validate_stores); route overlaps via ambiguous_dynamic_route.

No behavior change — test + changelog only.

PR #350 made moduleSource fail loudly when go list -m cannot determine
the main module and the generated app imports app-owned packages, but
only the decision heuristic (isLocalModuleImportPath /
appHasLocalModuleImports) was unit-tested; the error-propagation path
itself was not.

Add two integration tests that run outside any Go module (t.Chdir to an
empty temp dir, so go list -m fails with a real 'no go.mod' reason):
- with an app-owned inline go {} import, moduleSource surfaces
  'cannot determine the app Go module'
- with no app-owned imports, moduleSource tolerates the failure and
  still emits a valid generated go.mod

Full go test ./... (55 non-example packages) passes.
@cssbruno cssbruno merged commit 6909720 into main Jun 13, 2026
5 checks passed
@cssbruno cssbruno deleted the worktree-fail-loudly-gaps branch June 13, 2026 12:55
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