Skip to content

change: sort stylish issues; test only exported formatter functions - #1587

Merged
alexandear merged 9 commits into
mgechev:masterfrom
alexandear:refactor/formatter-tests-unexported
Dec 1, 2025
Merged

change: sort stylish issues; test only exported formatter functions#1587
alexandear merged 9 commits into
mgechev:masterfrom
alexandear:refactor/formatter-tests-unexported

Conversation

@alexandear

@alexandear alexandear commented Nov 21, 2025

Copy link
Copy Markdown
Collaborator

Replace existing tests that target unexported formatter functions with tests for exported.

Sort issues by files in stylish for consistency. Remove trailing whitespace.

Updates #1362

@alexandear
alexandear force-pushed the refactor/formatter-tests-unexported branch from c32457c to 60c4dee Compare November 21, 2025 16:08
@alexandear alexandear changed the title test: do not check nexported formatter functions Nov 21, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the formatter package tests to follow black-box testing principles by testing the exported Format() method of each formatter rather than unexported helper functions like printStatistics() and table(). The change aligns with Go best practices of testing public APIs and makes tests more resilient to internal implementation changes.

  • Removes tests for unexported printStatistics and table functions from formatter/friendly_test.go
  • Updates formatter/formatter_test.go to test all formatters through their public Format() method with realistic failure data
  • Adds github.com/google/go-cmp dependency for better diff output in test failures
  • Removes the testpackage linter exception for the formatter package in .golangci.yml, enabling black-box testing

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
go.mod Adds google/go-cmp v0.7.0 dependency for improved test assertions
go.sum Updates dependency checksums for google/go-cmp
formatter/friendly_test.go Removes white-box tests of unexported formatter helper functions
formatter/formatter_test.go Refactors to test all formatters via their exported Format() method with more comprehensive test data including multiple failures and severity levels
.golangci.yml Removes testpackage linter exception, enabling black-box testing for formatter package

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread formatter/formatter_test.go Outdated
Comment thread formatter/formatter_test.go Outdated
alexandear and others added 2 commits November 27, 2025 08:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread formatter/formatter_test.go Outdated
Comment thread go.mod Outdated
@alexandear
alexandear marked this pull request as draft November 28, 2025 08:20
@alexandear
alexandear marked this pull request as ready for review November 28, 2025 14:56
@alexandear
alexandear requested a review from Copilot November 28, 2025 14:56
@alexandear alexandear changed the title test: do not check unexported formatter functions Nov 28, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread formatter/stylish.go Outdated
Comment thread formatter/formatter_test.go Outdated
@alexandear
alexandear merged commit 3e6d16b into mgechev:master Dec 1, 2025
10 checks passed
@alexandear
alexandear deleted the refactor/formatter-tests-unexported branch December 1, 2025 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants