Skip to content

test: finish moving test sessions onto the real constructor - #412

Merged
David-Noble-at-work merged 1 commit into
developfrom
test-env-constructor-remainder
Aug 14, 2026
Merged

David-Noble-at-work merged 1 commit into
developfrom
test-env-constructor-remainder

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

Summary

Phase 2b, PR 2b.1b of windows-native-permissions.md
(#405) — and the completion of 2b.1.
26 sites across 12 files, leaving no _test.go that sets RuntimeEnvironment.Root in a struct
literal, so 2b.2 can privatize the field without dragging test conversions into the same diff.

Target Sites
pkg/op/provider/git (5 files) 11
cmd/star/provider/starcode 6
pkg/op/provider/{json,yaml,service,mem,function} 6
pkg/op/provider/file 3

Where judgment was needed

Two cases where the constructor's defaulting is the subject. mem's
TestNewResource_NilCatalogReturnsUnlinkedCandidate and file's mustRegular both depend on a
nil ResourceCatalog to produce an unlinked resource, and NewRuntimeEnvironment defaults one.
Routing them through the helper unchanged would have left the tests passing while testing nothing.
Both construct and then clear the catalog, with a comment. The rule is recorded in the plan: where
defaulting is the subject, construct and then undo — never route around the constructor.

A wrong comment corrected. file's BackupSuffix note claimed the constructor derives the
value; it never sets the field (runtime_environment.go:211). The value is
NewRuntimeEnvironmentConfig's builtin floor.

Two enumeration errors that cancelled, recorded because the cancellation is what would have let
them survive review: git had 11 sites, not 10 — a bare &op.RuntimeEnvironment{} invisible to
a Root:-anchored grep — and starlarkbridge had 0, not 1, because the counting regex matched
"Root" inside fixture names like bridgePlannedRootFixture. Total unchanged at 26; files 12, not 13.

Verification

make test zero failures. make lint-all zero issues on linux, darwin, and windows — run before
the commit
, which is what caught file's now-dead testRoot helper (deleted, not suppressed).
make test alone was happy with it.

test (windows-latest) is expected to hold at its known 28 failures; no production code changed.

Assisted-by: Claude

Phase 2b, PR 2b.1b of the native-Windows-permissions plan (#405), and
the completion of 2b.1: 26 sites across 12 files, leaving no _test.go
that sets RuntimeEnvironment.Root in a struct literal. 2b.2 can now make
the field private without dragging test conversions into the same diff.

Each package gains (or reuses) a local testEnvironment(t, dir) helper
calling NewRuntimeEnvironment with a spec. The conversion shrinks these
tests: the constructor already wires RecoverySite and defaults
ResourceCatalog, so the hand-assembled lines are deleted rather than
ported. git's narrating provider keeps a bespoke spec because it needs
WithStatus and a dry-run flag.

Two construction cases needed care, because the constructor's defaulting
is the very thing under test. mem's nil-catalog test and file's
mustRegular both depend on a nil ResourceCatalog to produce an unlinked
resource; both now construct through the helper and clear the catalog
afterward, with a comment saying why. The general rule, recorded in the
plan: where defaulting is the subject, construct and then undo -- never
route around the constructor.

file's BackupSuffix comment claimed NewRuntimeEnvironment derives the
value. It does not set the field at all; the value is
NewRuntimeEnvironmentConfig's builtin floor. Comment corrected.

Two enumeration errors are recorded in the plan because they cancelled,
which is what would have let them survive review: git had 11 sites not
10 (a bare &op.RuntimeEnvironment{} that a Root:-anchored grep cannot
see), and starlarkbridge had 0 not 1 (its literals set Modules; the
regex matched "Root" inside fixture names like bridgePlannedRootFixture).
The total stayed at 26; the file count was 12, not 13.

make lint-all flagged file's testRoot helper as dead once its last
caller was rewritten -- make test did not. Deleted rather than
suppressed, and the gate ran before this script was written.

Verified: make test zero failures; make lint-all zero issues on linux,
darwin, and windows.

The plan also marks phase 3 as sequenced after 2b rather than blocked,
since phase 2's CI gate is proved and 2b.2's design is ruled.

Assisted-by: Claude
Signed-off-by: David Noble <[email protected]>
@David-Noble-at-work David-Noble-at-work self-assigned this Aug 14, 2026
@David-Noble-at-work
David-Noble-at-work merged commit 7d7aac3 into develop Aug 14, 2026
7 of 8 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the test-env-constructor-remainder branch August 14, 2026 22:08
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