Skip to content

Improve test quality: pkg/cli/update_cooldown_test.go#29522

Merged
pelikhan merged 2 commits intomainfrom
copilot/testify-expert-improve-test-quality-another-one
May 1, 2026
Merged

Improve test quality: pkg/cli/update_cooldown_test.go#29522
pelikhan merged 2 commits intomainfrom
copilot/testify-expert-improve-test-quality-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

Addresses several test quality gaps in the release cooldown test suite: missing named subtests, five separate TestCheckReleaseCoolDown_* functions that should be one table-driven test, weak message assertions, and a missing negative-duration edge case.

Changes

  • TestIsExemptFromCoolDown — Added name field to struct; subtests now use t.Run(tt.name, ...) instead of the repo path string
  • TestCheckReleaseCoolDown_*TestCheckReleaseCoolDown — Consolidated 5 separate functions into a single table-driven test; strengthens PublishedAt check to assert exact value equality (not just non-zero) and asserts IsZero() on paths that shouldn't populate it
  • TestCheckReleaseCoolDownWithDate_InCoolDown — Adds assertions on "cool down", "remaining", and "owner/repo" in the message body
  • TestCheckReleaseCoolDownWithDate_NotInCoolDown — Adds PublishedAt.IsZero() and assert.Empty(Message) assertions (this variant never populates PublishedAt)
  • TestFormatCoolDownDuration — Adds -1 * time.Hour → "< 1h" case to cover the negative-duration clamp path

Copilot AI changed the title [WIP] Improve test quality for update_cooldown_test.go Improve test quality: pkg/cli/update_cooldown_test.go May 1, 2026
Copilot AI requested a review from gh-aw-bot May 1, 2026 11:15
@pelikhan pelikhan marked this pull request as ready for review May 1, 2026 11:17
Copilot AI review requested due to automatic review settings May 1, 2026 11:17
@pelikhan pelikhan merged commit 097d42d into main May 1, 2026
19 checks passed
@pelikhan pelikhan deleted the copilot/testify-expert-improve-test-quality-another-one branch May 1, 2026 11:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves the reliability and readability of the release cooldown test suite by strengthening assertions and consolidating repetitive cases into table-driven subtests.

Changes:

  • Added named subtests to TestIsExemptFromCoolDown.
  • Consolidated multiple TestCheckReleaseCoolDown_* tests into one table-driven test with stronger PublishedAt assertions.
  • Strengthened cooldown message assertions and added a negative-duration edge case to duration formatting tests.
Show a summary per file
File Description
pkg/cli/update_cooldown_test.go Refactors cooldown tests for clearer subtest naming, broader scenario coverage, and stronger assertions around timestamps/messages.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

{"notactions/checkout", false},
{"notgithub/repo", false},
{name: "actions namespace", repo: "actions/checkout", want: true},
{name: "actions namespace with version", repo: "actions/setup-node", want: true},
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

Test case name "actions namespace with version" is misleading because the input repo value doesn't include a version (and gitutil.ExtractBaseRepo only handles subpaths, not @ref). Consider renaming the subtest to reflect what's actually being exercised (e.g., just another actions/* repo) to avoid confusion for future readers.

Suggested change
{name: "actions namespace with version", repo: "actions/setup-node", want: true},
{name: "another actions namespace repo", repo: "actions/setup-node", want: true},

Copilot uses AI. Check for mistakes.
@github-actions github-actions Bot mentioned this pull request May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

🧪 Test Quality Sentinel Report

Test Quality Score: 96/100

Excellent test quality

Metric Value
New/modified tests analyzed 8
✅ Design tests (behavioral contracts) 8 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 7 (87.5%)
Duplicate test clusters 0
Test inflation detected No
🚨 Coding-guideline violations 0

Test Classification Details

📋 All 8 Test Functions
Test File Classification Notes
TestParseCoolDownFlag pkg/cli/update_cooldown_test.go ✅ Design Table-driven; 5 happy-path + 4 error cases; all assertions have descriptive messages
TestIsExemptFromCoolDown pkg/cli/update_cooldown_test.go ✅ Design Table-driven; 10 cases including negative matches (notactions/, notgithub/); verifies observable bool return
TestCheckReleaseCoolDown pkg/cli/update_cooldown_test.go ✅ Design Table-driven; covers disabled cooldown, old release, recent release, and network-error path; swaps injectable getReleasePublishedAtFn correctly
TestCheckReleaseCoolDownWithDate_InCoolDown pkg/cli/update_cooldown_test.go ✅ Design Verifies InCoolDown, Message content (tag, "cool down", "remaining", repo) — genuine behavioral contract
TestCheckReleaseCoolDownWithDate_NotInCoolDown pkg/cli/update_cooldown_test.go ✅ Design Verifies zero PublishedAt and empty Message when release is outside the window
TestCheckReleaseCoolDownWithDate_ZeroDuration pkg/cli/update_cooldown_test.go ✅ Design Edge case: zero cooldown duration always allows update
TestCheckReleaseCoolDownWithDate_FutureTimestamp pkg/cli/update_cooldown_test.go ✅ Design Edge case: future-dated release (clock skew) treated as just-published and kept in cooldown
TestFormatCoolDownDuration pkg/cli/update_cooldown_test.go ✅ Design Table-driven; 9 cases including zero, negative, and sub-hour durations that all map to "< 1h"

Flagged Tests — Requires Review

No tests flagged. All tests meet the quality bar.


Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 8 tests — unit (//go:build !integration)
  • 🟨 JavaScript (*.test.cjs, *.test.js): 0 tests

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). All 8 tests verify observable behavioral contracts with descriptive assertion messages. No coding-guideline violations detected.


📊 Score Breakdown
Component Max Earned Reason
Behavioral Coverage 40 40 8/8 design tests (100%)
Error/Edge Case Coverage 30 26 7/8 tests have error or edge-case rows (87.5%)
Low Duplication 20 20 No duplicate clusters detected
Proportional Growth 10 10 Test additions (81) vs. production additions (143) = 0.57:1 — well below the 2:1 threshold
Total 100 96
📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

References: §25212425298

🧪 Test quality analysis by Test Quality Sentinel · ● 605.4K ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 96/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). All 8 tests verify observable behavioral contracts with descriptive assertion messages and proper build tags.

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/update_cooldown_test.go

4 participants