Modernize sliceutil tests to use testify assertions#10029
Merged
Conversation
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
- Add testify/assert import statement - Convert all table-driven tests to use assert.Equal - Convert all edge case tests to use assert.True/False - Improve assertion messages for better test failure diagnostics - No functional changes - only assertion style updates Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve test quality in sliceutil_test.go
Modernize sliceutil tests to use testify assertions
Jan 15, 2026
This was referenced Jan 15, 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.
The
pkg/sliceutil/sliceutil_test.gofile used manualif result != expectedchecks witht.Error()calls instead of testify assertions, inconsistent with repository standards documented inspecs/testing.md.Changes
github.com/stretchr/testify/assertassert.Equal(t, expected, result, message)in:TestContainsTestContainsAnyTestContainsIgnoreCaseTestContainsIgnoreCase_Unicodeassert.True()/assert.False()in:TestContains_LargeSliceTestContains_SingleElementTestContainsAny_MultipleMatchesTestContainsAny_NilSubstringsTestContainsIgnoreCase_PartialMatchTestContains_DuplicatesTestContainsAny_OrderMattersExample
Reduced code by 35 lines while improving test failure diagnostics and maintainability.
Original prompt
This section details on the original issue you should resolve
<issue_title>[testify-expert] Improve Test Quality: ./pkg/sliceutil/sliceutil_test.go</issue_title>
<issue_description>## Overview
The test file
./pkg/sliceutil/sliceutil_test.gohas been selected for quality improvement by the Testify Uber Super Expert. This test file demonstrates excellent table-driven test structure and comprehensive coverage, but it uses manual error checking (if result != expected) instead of testify assertions. Modernizing to use testify will provide clearer error messages, better test output, and align with the repository's testing standards documented inspecs/testing.md.Current State
./pkg/sliceutil/sliceutil_test.go./pkg/sliceutil/sliceutil.goTest Quality Analysis
Strengths ✅
TestContains,TestContainsAny,TestContainsIgnoreCase) use proper table-driven patterns with descriptive test case namesAreas for Improvement 🎯
1. Testify Assertions
Current Issues:
if result != expectedchecks witht.Error()ort.Errorf()require) and test validations (should useassert)Recommended Changes:
Why this matters:
specs/testing.md) requires testify assertionsrequire.*) and validations (assert.*)2. Import Statement
Current Issue:
"github.com/stretchr/testify/assert"Recommended Change:
3. Edge Case Tests - Use Table-Driven Pattern
Current Issues:
TestContains_LargeSlice,TestContains_SingleElement, etc. use manual assertionsRecommended Improvements:
Example 1: TestContains_LargeSlice
Example 2: TestContains_SingleElement
Example 3: TestContainsAny_MultipleMatches
Example 4: TestContainsIgnoreCase_PartialMatch
4. Consider assert.Contains for Slice Checks
Current Pattern:
**Alternative (when expecting ...
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.