Modernize console render tests with testify assertions#13722
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes the console render tests by replacing manual error checking with testify assertions, improving test readability and failure diagnostics.
Changes:
- Replaced ~60 manual
strings.Containschecks andt.Error/t.Errorfcalls with testify'sassert.Contains,assert.NotContains,assert.Equal, andassert.Len - Removed unused
stringsimport (no longer needed after assertion migration) - Added descriptive assertion messages following repository conventions
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The console rendering tests relied on manual
strings.Contains/t.Errorfchecks, leading to noisy failures and inconsistent style.pkg/console/render_test.gowithtestify/assertfor clearer failures across struct, map, slice, formatting, and tag parsing cases.github.com/stretchr/testify/assertimport and removed unusedstrings.Example:
Original prompt
This section details on the original issue you should resolve
<issue_title>[testify-expert] Improve Test Quality: pkg/console/render_test.go</issue_title>
<issue_description>### Overview
The test file
pkg/console/render_test.gohas been selected for quality improvement by the Testify Uber Super Expert. This file contains comprehensive tests for the console rendering system but uses zero testify assertions, relying entirely on plain Go error handling. This issue provides specific, actionable recommendations to modernize these tests using testify best practices.Current State
pkg/console/render_test.gopkg/console/render.goTest Quality Analysis
Strengths ✅
TestParseConsoleTag,TestIsZeroValue,TestFormatFieldValue, andTestFormatNumberalready use table-driven patternsAreas for Improvement 🎯
1. Testify Assertions (CRITICAL - Entire File)
Current Issues:
t.Error(),t.Errorf()strings.Contains()Impact:
scratchpad/testing.md)Recommended Changes:
Why this matters: Testify provides:
2. Import Statement Required
Action Needed:
Add testify import at the top of the test file:
3. Specific Test Conversions
Priority High - Most Impactful Conversions:
TestRenderStruct_SimpleStruct (lines 32-58)
assert.Contains/assert.NotContainsTestRenderStruct_OmitEmpty (lines 60-89)
assert.ContainsTestRenderSlice_AsTable (lines 91-115)
assert.ContainsTestRenderMap (lines 117-138)
assert.ContainsTestParseConsoleTag (lines 140-210)
assert.EqualTestIsZeroValue (lines 212-238)
assert.EqualTestFormatFieldValue (lines 240-262)
assert.EqualTestFormatNumber (lines 396-449)
assert.Equal