[cloclo] fix(types): use assert.InDelta and assert.Empty to fix lint in spec_test.go#27346
Conversation
Replace assert.Equal with assert.InDelta (delta=1e-9) for all float64 comparisons in pkg/types/spec_test.go to satisfy the testifylint float-compare check. Also replace assert.Equal(t, "", ...) with assert.Empty to satisfy the testifylint nil-empty check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3425124
into
spec-enforcer/2026-04-20-tty-types-workflow-b230cdde53b4c9a6
There was a problem hiding this comment.
Pull request overview
Updates specification-driven tests to satisfy testifylint requirements and keep spec tests aligned with documented package contracts.
Changes:
- Adds spec tests for
tty,types, andworkflowpackages. - Updates floating-point comparisons to use
assert.InDeltaand empty-string checks to useassert.Empty(pertestifylint). - Introduces/expands spec coverage for workflow permissions factories and safe-outputs config helpers.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/spec_test.go | Adds spec tests for permissions factory helpers and SafeOutputsConfigFromKeys. |
| pkg/types/spec_test.go | Adds/updates spec tests for MCP server/auth config and token weights, using linter-compliant assertions. |
| pkg/tty/spec_test.go | Adds spec tests for terminal detection behavior contracts. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (3)
pkg/types/spec_test.go:136
- In
TestSpec_Types_MCPAuthConfig, the “auth without explicit audience” case expectsAudienceto be empty (wantAud: ""), but the package spec/README states the audience defaults to the server URL when omitted. This test currently contradicts that documented behavior (and the assertion message also mentions the default). Please align the expectation and/or the documentation so the spec test enforces the intended contract.
{
name: "auth without explicit audience",
auth: types.MCPAuthConfig{
Type: "github-oidc",
},
wantType: "github-oidc",
wantAud: "",
},
pkg/types/spec_test.go:6
- The PR title/description say this is only a lint-fix in
pkg/types/spec_test.go, but this PR also adds new spec tests inpkg/tty/spec_test.goandpkg/workflow/spec_test.go(and the fullpkg/types/spec_test.gofile). Please update the PR title/description to reflect the additional scope, or split the extra files into a separate PR if they’re unrelated to the lint fix.
//go:build !integration
package types_test
import (
"encoding/json"
pkg/types/spec_test.go:88
TestSpec_Types_BaseMCPServerConfig_JSONRoundTrip(and its comment) says it validates bothjsonandyamlstruct tags, but the test only does a JSON marshal/unmarshal. Either extend this test to also round-trip via YAML (or reflect on struct tags), or rename/reword it so it doesn’t claim YAML coverage.
// TestSpec_Types_BaseMCPServerConfig_JSONRoundTrip validates that BaseMCPServerConfig fields
// use both json and yaml struct tags as documented in the Design Notes section of the README.
// Spec: "All struct fields use both json and yaml struct tags so they can be round-tripped
// through both serialization formats."
func TestSpec_Types_BaseMCPServerConfig_JSONRoundTrip(t *testing.T) {
original := types.BaseMCPServerConfig{
Type: "stdio",
- Files reviewed: 1/1 changed files
- Comments generated: 0
🧪 Test Quality Sentinel ReportTest Quality Score: 76/100
Test Classification DetailsView all 17 test classifications
Flagged Tests — Suggestions for Review
|
| Component | Score |
|---|---|
| Behavioral Coverage (17/17 design tests) | 40/40 |
| Error/Edge Case Coverage (6/17 tests have edge cases) | ~11/30 |
| Low Duplication (1 cluster × −5) | 15/20 |
| Proportional Growth (test-only PR, no inflation) | 10/10 |
| Total | 76/100 |
Verdict
✅ Check passed. 0% of new tests are implementation tests (threshold: 30%). All tests verify behavioral contracts and all Go test files have the required
//go:build !integrationtag. The main opportunity is consolidating the 7 structurally-similar permission factory tests and adding negative assertions (absent scopes).
📖 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: §24669065128
🧪 Test quality analysis by Test Quality Sentinel · ● 488.4K · ◷
There was a problem hiding this comment.
✅ Test Quality Sentinel: 76/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%). All 17 tests verify behavioral contracts; all files have required build tags; no mock libraries used. See comment for improvement suggestions (consolidating the 7 permission factory tests into a table-driven test with negative assertions).
$(cat <<'EOF'
Fixes the
lint-gofailure in PR #27305 (spec-enforcer/2026-04-20-tty-types-workflow-b230cdde53b4c9a6).What failed
The
testifylintlinter (enabled viaenable-all: truein.golangci.yml) reported two categories of violations inpkg/types/spec_test.go:float-compare:assert.Equalwas used to comparefloat64values. The linter requiresassert.InDeltaorassert.InEpsilonfor floating-point comparisons.nil-empty(sub-check ofempty):assert.Equal(t, "", ...)was used to check for an empty string; the linter requiresassert.Empty.Changes
pkg/types/spec_test.goonly:assert.Equal(t, <float64>, ...)calls withassert.InDelta(t, <float64>, ..., 1e-9, ...)inTestSpec_Types_TokenWeightsandTestSpec_Types_TokenClassWeightsassert.Equal(t, "", cfg.Type, ...)withassert.Empty(t, cfg.Type, ...)inTestSpec_Types_ZeroValueSafetyTest plan
lint-gojob passestestjob continues to pass (logic unchanged, only assertion style updated)References:
EOF