Refactor code and improve test assertions - #120
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors several core paths (worker execution, log loading, TOML defaults) and modernizes tests to make assertions clearer and to exercise concurrency behavior more reliably.
Changes:
- Extracted worker command execution-with-timeout into a helper and cleaned up category variable naming.
- Centralized TOML defaulting logic into small helper functions and expanded default fields (e.g., favicon).
- Improved tests by switching to
testify/assert, adding coverage forIf-Modified-Since, and refactoring the race scenario test into helper loops.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| worker.go | Refactors per-service timeout execution into a dedicated helper called from the worker pool. |
| tomp_test.go | Replaces manual assertions with testify/assert for clearer test failures. |
| toml.go | Extracts repeated “set default if empty” logic into helper functions and applies them during TOML load. |
| scenario_race_test.go | Refactors concurrent scenario test into helper loops to reduce duplication. |
| logs.go | Refactors log initialization/status computations into smaller methods and improves naming/comment clarity. |
| handlers.go | Simplifies ifModifiedSince condition expression. |
| handlers_test.go | Adds a focused unit test for ifModifiedSince. |
| go.mod | Adds testify (and related transitive deps) to support new test assertions. |
| go.sum | Updates sums for newly added/updated module dependencies. |
Comments suppressed due to low confidence (1)
toml.go:155
stringDefaulthas the same nil-guard issue asmarkdownDefault: whens == nilthe function will still dereference*sand panic. If nil pointers are not expected, drop the check; otherwise return early whensis nil.
func stringDefault(s *string, defaultValue string) {
if s == nil || *s == "" {
*s = defaultValue
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
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.



No description provided.