[test-improver] Improve tests for server shutdown - #4852
Merged
lpcox merged 2 commits intoApr 30, 2026
Conversation
- Replace manual t.Errorf('Expected error field in response') with idiomatic
testify assertions using require.Contains and assert.Equal
- Add t.Parallel() to top-level test functions for better test isolation
and parallelism
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the shutdown behavior tests in internal/server by improving assertion patterns and attempting to speed up execution via parallelism.
Changes:
- Adds
t.Parallel()to the routed and unified shutdown behavior tests. - Replaces manual JSON field/type checks with
require.Contains+assert.Equalfor clearer failures.
Show a summary per file
| File | Description |
|---|---|
internal/server/shutdown_test.go |
Updates shutdown tests with improved testify assertions and enables parallel execution for two top-level test functions. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
internal/server/shutdown_test.go:113
- Adding t.Parallel() here can make this test run concurrently with other shutdown tests, and /close ultimately calls guard.CloseGlobalCompilationCache() (documented as not safe to call concurrently). This can introduce flakiness/undefined behavior; consider removing t.Parallel() for this test or making the shutdown path avoid/serialize the global cache close in tests.
t.Parallel()
- Files reviewed: 1/1 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
lpcox
deleted the
test-improver/shutdown-test-improvements-80981fad6765b4ae
branch
April 30, 2026 13:43
This was referenced Apr 30, 2026
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.
Test Improvements:
shutdown_test.goFile Analyzed
internal/server/shutdown_test.gointernal/serverImprovements Made
1. Better Testify Assertions
Replaced manual
if/elsetype-assertion blocks with idiomatic testify assertions:Before:
After:
require.Containsnow fails fast with a clear message if"error"key is missingassert.Equaldirectly compares the value without the awkward type assertiont.Errorfin favour of testify's consistent assertion API2. Parallel Test Execution
t.Parallel()toTestShutdownBehavior_RoutedModeandTestShutdownBehavior_UnifiedModeThese tests are self-contained and create their own server/handler per subtest, so they are safe to run in parallel.
Test Execution
All tests pass:
Why These Changes?
The
shutdown_test.gofile was using rawt.Errorfin a few places where testify'srequire.Contains+assert.Equalprovides clearer failure messages and better integrates with the rest of the testify-based test suite. Thet.Parallel()additions allow the test runner to execute these independent table-driven tests concurrently, reducing total test time.Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests