Refactor strings_test.go to use testify assertions#9894
Merged
Conversation
- Add testify/assert import - Replace manual length checks and loops with assert.Equal - Add helpful assertion messages for all tests - Reduce test code from 445 to 425 lines (-20 lines) - All 5 test functions refactored: TestSortStrings, TestSortPermissionScopes, TestSanitizeWorkflowName, TestShortenCommand, TestSanitizeName Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve test quality in strings_test.go
Refactor strings_test.go to use testify assertions
Jan 14, 2026
This was referenced Jan 14, 2026
5 tasks
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.
Replace manual assertion loops with
testify/assert.Equalfor clearer test failures and improved diff output.Changes
github.com/stretchr/testify/assertassert.Equalcalls across all 5 test functionsExample
Before:
After:
Testify automatically handles slice comparison and provides structured diff output on failure, showing visual side-by-side comparison instead of individual element mismatches.
Functions Updated
TestSortStrings(6 cases)TestSortPermissionScopes(5 cases)TestSanitizeWorkflowName(14 cases)TestShortenCommand(8 cases)TestSanitizeName(21 cases)All 58 subtests pass with identical behavior.
Original prompt
This section details on the original issue you should resolve
<issue_title>[testify-expert] Improve Test Quality: pkg/workflow/strings_test.go</issue_title>
<issue_description>## Overview
The test file
pkg/workflow/strings_test.gohas been selected for quality improvement by the Testify Uber Super Expert. While this test file demonstrates excellent use of table-driven tests and comprehensive coverage, there are opportunities to enhance it by adopting testify assertions for clearer error messages and better debugging experience.Current State
pkg/workflow/strings_test.gopkg/workflow/strings.goTest Quality Analysis
Strengths ✅
t.Run()for subtests with clear namingAreas for Improvement 🎯
1. Testify Assertions
Current Issues:
t.Errorf()instead of testify assertionst.Errorf()patternRecommended Changes:
Why this matters:
specs/testing.md)2. Imports and Package Setup
Current State:
Recommended:
3. Consistent Assertion Pattern
Recommended Pattern for String Comparisons:
Recommended Pattern for Slice Comparisons:
Benefits:
assert.Equalautomatically shows detailed diffs for slices4. Specific Functions to Update
Priority Order (High to Low):
TestSortStrings(lines 5-63)assert.Equal(t, tt.expected, result)TestSortPermissionScopes(lines 65-118)assert.EqualTestSanitizeWorkflowName(lines 120-206)assert.Equal(t, tt.expected, result, message)TestShortenCommand(lines 208-264)✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.