Repository navigation
test: finish moving test sessions onto the real constructor - #412
Merged
Merged
Conversation
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]>
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.
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.gothat setsRuntimeEnvironment.Rootin a structliteral, so 2b.2 can privatize the field without dragging test conversions into the same diff.
pkg/op/provider/git(5 files)cmd/star/provider/starcodepkg/op/provider/{json,yaml,service,mem,function}pkg/op/provider/fileWhere judgment was needed
Two cases where the constructor's defaulting is the subject.
mem'sTestNewResource_NilCatalogReturnsUnlinkedCandidateandfile'smustRegularboth depend on anil
ResourceCatalogto produce an unlinked resource, andNewRuntimeEnvironmentdefaults 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'sBackupSuffixnote claimed the constructor derives thevalue; it never sets the field (
runtime_environment.go:211). The value isNewRuntimeEnvironmentConfig's builtin floor.Two enumeration errors that cancelled, recorded because the cancellation is what would have let
them survive review:
githad 11 sites, not 10 — a bare&op.RuntimeEnvironment{}invisible toa
Root:-anchored grep — andstarlarkbridgehad 0, not 1, because the counting regex matched"Root" inside fixture names like
bridgePlannedRootFixture. Total unchanged at 26; files 12, not 13.Verification
make testzero failures.make lint-allzero issues on linux, darwin, and windows — run beforethe commit, which is what caught
file's now-deadtestRoothelper (deleted, not suppressed).make testalone was happy with it.test (windows-latest)is expected to hold at its known 28 failures; no production code changed.Assisted-by: Claude