Skip to content

test(semver): upgrade semver_precise_test.go to testify + expand coverage - #48960

Merged
pelikhan merged 4 commits into
mainfrom
copilot/testify-expert-improve-test-quality-one-more-time
Jul 29, 2026
Merged

test(semver): upgrade semver_precise_test.go to testify + expand coverage#48960
pelikhan merged 4 commits into
mainfrom
copilot/testify-expert-improve-test-quality-one-more-time

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

pkg/cli/semver_precise_test.go was the only test file in pkg/cli not using testify, and had gaps in coverage for IsNewer, invalid inputs, and pre-release versions.

Changes

  • Testify migration — replaced all raw if/t.Errorf/t.Fatalf with require/assert; require.NotNil now short-circuits subtests on parse failure instead of manual nil-check + Fatalf
  • Invalid input coverage — added "not-a-version" and "" cases to TestIsPreciseVersion using require.Nil to assert parseVersion returns nil
  • Pre-release coverage — added v1.2.3-rc.1 case confirming it is treated as precise (dotCount >= 2 on Raw)
  • TestIsNewer table — new test covering newer/older major, minor, patch, and equal versions in both directions
  • Table-driven TestPreciseVersionPreference — refactored from a single hardcoded v6/v6.0.0 scenario to a table with three equivalent-version pairs (v6, v6.0, 6.1)
  • File comment — clarifies this file tests the pkg/cli parseVersion wrapper, not full semverutil logic

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.5 AIC · ⌖ 7.46 AIC · ⊞ 7.8K ·
Comment /souschef to run again

…ases, TestIsNewer table

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve test quality for semver_precise_test.go test(semver): upgrade semver_precise_test.go to testify + expand coverage Jul 29, 2026
Copilot AI requested a review from pelikhan July 29, 2026 18:54
@pelikhan
pelikhan marked this pull request as ready for review July 29, 2026 19:17
Copilot AI review requested due to automatic review settings July 29, 2026 19:17

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

Updates CLI semantic-version tests to use Testify and broaden parsing and comparison coverage for issue #48958.

Changes:

  • Migrates assertions to assert and require.
  • Adds invalid, pre-release, comparison, and equivalent-version cases.
  • Documents test scope.
Show a summary per file
File Description
pkg/cli/semver_precise_test.go Expands and refactors semantic-version tests.

Review details

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment thread pkg/cli/semver_precise_test.go Outdated
Comment on lines +73 to +75
name: "pre-release suffix - precise",
version: "v1.2.3-rc.1",
expected: true,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the same commit. Removed the duplicate TestIsNewer table from semver_precise_test.go and migrated TestVersionIsNewer in semver_test.go to use require/assert from testify, consolidating the migration into the existing (more complete) test.

Comment thread pkg/cli/semver_precise_test.go Outdated
Comment on lines +92 to +97
func TestIsNewer(t *testing.T) {
tests := []struct {
name string
v1 string
v2 string
newer bool

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit fix(semver): count only core-version dots.... IsPreciseVersion now strips pre-release and build-metadata suffixes before counting dots, so only the core version components are evaluated. Added v1.2-rc.1 as a wantNil: true boundary case — since golang.org/x/mod/semver rejects a pre-release on a sub-three-part base, parseVersion returns nil, confirming an imprecise core with a dotted suffix is never misclassified as precise.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address these unresolved review comments, and rerun any required checks once done.

Unresolved review threads:

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.5 AIC · ⌖ 7.46 AIC · ⊞ 7.8K ·
Comment /souschef to run again

… duplicate TestIsNewer; migrate TestVersionIsNewer to testify

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI requested a review from gh-aw-bot July 29, 2026 19:42
@pelikhan
pelikhan merged commit ec7e9b2 into main Jul 29, 2026
29 checks passed
@pelikhan
pelikhan deleted the copilot/testify-expert-improve-test-quality-one-more-time branch July 29, 2026 19:52
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[testify-expert] Improve Test Quality: pkg/cli/semver_precise_test.go

4 participants