Conversation
Replace manual error checking with idiomatic testify assertions and add
a new table-driven test covering the previously untested default branch
in getEmojiForLevel.
Changes:
- assert.True(t, strings.Contains(...)) -> assert.Contains
- assert.False(t, codeBlockCount < 2) -> assert.GreaterOrEqual
- Manual if+t.Errorf loops -> assert.Contains / assert.NotContains
- os.Stat existence checks -> assert.DirExists / assert.FileExists
- if err != nil { t.Fatalf } -> require.NoError
- Add TestGetEmojiForLevel covering all levels including default bullet
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the internal/logger markdown logger tests by standardizing assertions on testify (better consistency and failure output) and adding explicit branch coverage for getEmojiForLevel, including the default/unknown-level case.
Changes:
- Replaced manual
if+t.Errorf/t.Fatalfchecks withassert.*/require.*equivalents throughoutmarkdown_logger_test.go. - Improved intent clarity in a few assertions (e.g.,
GreaterOrEqualfor code fence counts). - Added
TestGetEmojiForLevelto cover all switch branches, including the default"•"case.
💡 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.
Test Improvements:
markdown_logger_test.goFile Analyzed
internal/logger/markdown_logger_test.gointernal/loggerImprovements Made
1. Better Testing Patterns
The file previously mixed testify assertions with 14 manual
if/t.Errorf/t.Fatalfchecks. All have been replaced with idiomatic testify equivalents for consistency and better error messages:if _, err := os.Stat(path); os.IsNotExist(err) { t.Errorf(...) }→assert.DirExists/assert.FileExistsassert.True(t, strings.Contains(content, x), msg)→assert.Contains(t, content, x, msg)assert.False(t, count < 2, msg)→assert.GreaterOrEqual(t, count, 2, msg)(clearer intent)if !strings.Contains(content, x) { t.Errorf(...) }loops →assert.Containsin loopif strings.Contains(content, secret) { t.Errorf(...) }loops →assert.NotContainsin loopif err != nil { t.Fatalf(...) }→require.NoError(t, err, ...)(stops test on failure as intended)2. Increased Coverage
TestGetEmojiForLevel— a table-driven test covering all five branches ofgetEmojiForLevel, including the previously untested default"•"bullet case (reached only by an unknownLogLevelvalue)LogLevelInfo→"✓"LogLevelWarn→"⚠️"LogLevelError→"✗"LogLevelDebug→"🔍"default→"•"3. Cleaner & More Stable Tests
strings.Containsin assertion position — testify'sassert.Containsprovides better failure messages showing both the haystack and the needleif/negate/message patternWhy This File?
markdown_logger_test.goused testify for some assertions but fell back to manualif+t.Errorf/Fatalffor others — an inconsistency that made the tests harder to read and produced weaker failure messages. The file also leftgetEmojiForLevel's default branch completely untested despite being in the same package.Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests