Add RecordingRunner and Execute() test suite; fix cache/persist bugs#374
Open
kindermax wants to merge 1 commit into
Open
Add RecordingRunner and Execute() test suite; fix cache/persist bugs#374kindermax wants to merge 1 commit into
kindermax wants to merge 1 commit into
Conversation
- Add util.WriteFileAtomic (write-to-temp + rename) and use it in both remote config and mixin persist paths; removes the duplicate writeCacheAtomic from load.go and makes mixin cache writes atomic - Make remote mixin download fallback symmetric with ensureRemoteConfig: always fall back to cached version on download failure regardless of noCache, and surface both errors when the fallback read also fails - Fix LoadRemote to pass opts.noCache (not the raw positional bool) to ensureRemoteConfig so WithNoCache() alone fully applies the flag to the top-level remote config, not just mixins
Contributor
Reviewer's GuideAdds a RecordingRunner test double and a comprehensive Execute() test suite for the executor, while fixing caching and persistence behavior for remote configs and mixins and extracting a shared atomic file write helper. Sequence diagram for updated remote mixin download and cache fallback behaviorsequenceDiagram
participant Config
participant RemoteMixin
Config->>RemoteMixin: download(ctx, progress)
alt downloadErr is nil
RemoteMixin-->>Config: data
else downloadErr is not nil
RemoteMixin->>RemoteMixin: tryRead()
alt readErr is not nil
RemoteMixin-->>Config: error(downloadErr and readErr)
else cachedData is not nil
RemoteMixin-->>Config: cachedData
else cachedData is nil
RemoteMixin-->>Config: error(downloadErr)
end
end
Flow diagram for shared atomic file write helper usageflowchart TD
A[LoadRemote] --> B[ensureRemoteConfig]
B --> C[util.WriteFileAtomic]
D[RemoteMixin.persist] --> C
C --> E[Cache file safely updated]
C --> F[Remote mixin file safely persisted]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
readMixin, the combined error when both download and cache read fail only wraps the download error (%w) while printing the cache-read error with%v; consider wrapping the read error as well (e.g., viaerrors.Joinor a second%w) so callers can programmatically inspect both failures. - The new
WriteFileAtomichelper is a good centralization of the atomic-write logic; you might want to audit and migrate any other directos.WriteFile/OpenFileusages for config-like data to this helper to avoid partial writes elsewhere and keep behavior consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `readMixin`, the combined error when both download and cache read fail only wraps the download error (`%w`) while printing the cache-read error with `%v`; consider wrapping the read error as well (e.g., via `errors.Join` or a second `%w`) so callers can programmatically inspect both failures.
- The new `WriteFileAtomic` helper is a good centralization of the atomic-write logic; you might want to audit and migrate any other direct `os.WriteFile` / `OpenFile` usages for config-like data to this helper to avoid partial writes elsewhere and keep behavior consistent.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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
RecordingRunnertest double and a comprehensive table-drivenExecute()test suite inpackage executor--no-cachewas set; it is now unconditional (consistent withensureRemoteConfig), and both the download error and the cache-read error are surfaced when the fallback also failsWithNoCache()alone only half-applied the flag — mixins were force-downloaded but the top-level remote config still read from cache; fixed by passingopts.noCache(not the raw positional bool) toensureRemoteConfigpersistwrote directly to the cache file in-place, leaving it truncated on a mid-write crash; replaced withutil.WriteFileAtomic(write-to-temp + rename), extracted from the duplicatewriteCacheAtomicthat already existed inload.goTest plan
go test ./internal/executor/...— all 11 new Execute() tests passgo test ./internal/config/...— existing load + config tests pass including no-cache integration testsgo test ./internal/util/...— passesgo build ./...— clean buildSummary by Sourcery
Add an atomic file write helper, use it for remote configs and mixin persistence, and introduce a RecordingRunner-based Execute() test suite for the executor.
Bug Fixes:
Enhancements:
Tests: