Skip to content

Commit fecca41

Browse files
Copilotpelikhan
andauthored
Fix lint-go failure from testifylint violations in spec tests (#26686)
* Initial plan * chore: plan lint-go failure fix Agent-Logs-Url: https://github.com/github/gh-aw/sessions/917b8211-10ac-4695-b78b-05ed10d6362a Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * fix: resolve lint-go testifylint failures in spec tests Agent-Logs-Url: https://github.com/github/gh-aw/sessions/917b8211-10ac-4695-b78b-05ed10d6362a Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 3ec1794 commit fecca41

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

pkg/stats/spec_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ func TestSpec_PublicAPI_EmptyBehavior(t *testing.T) {
2020
var sv StatVar
2121

2222
assert.Equal(t, 0, sv.Count(), "Count should return 0 for an empty StatVar")
23-
assert.Equal(t, 0.0, sv.Sum(), "Sum should return 0 for an empty StatVar")
24-
assert.Equal(t, 0.0, sv.Min(), "Min should return 0 when no observations have been added")
25-
assert.Equal(t, 0.0, sv.Max(), "Max should return 0 when no observations have been added")
26-
assert.Equal(t, 0.0, sv.Mean(), "Mean should return 0 when no observations have been added")
27-
assert.Equal(t, 0.0, sv.Median(), "Median should return 0 when no observations have been added")
23+
assert.InDelta(t, 0.0, sv.Sum(), 1e-9, "Sum should return 0 for an empty StatVar")
24+
assert.InDelta(t, 0.0, sv.Min(), 1e-9, "Min should return 0 when no observations have been added")
25+
assert.InDelta(t, 0.0, sv.Max(), 1e-9, "Max should return 0 when no observations have been added")
26+
assert.InDelta(t, 0.0, sv.Mean(), 1e-9, "Mean should return 0 when no observations have been added")
27+
assert.InDelta(t, 0.0, sv.Median(), 1e-9, "Median should return 0 when no observations have been added")
2828
}
2929

3030
// TestSpec_PublicAPI_Add validates that each Add call records exactly one
@@ -54,7 +54,7 @@ func TestSpec_PublicAPI_Sum(t *testing.T) {
5454
sv.Add(2.0)
5555
sv.Add(3.0)
5656

57-
assert.Equal(t, 6.0, sv.Sum(),
57+
assert.InDelta(t, 6.0, sv.Sum(), 1e-9,
5858
"Sum should equal the arithmetic sum of all added observations")
5959
}
6060

@@ -71,9 +71,9 @@ func TestSpec_PublicAPI_MinMax(t *testing.T) {
7171
sv.Add(9.0)
7272
sv.Add(3.0)
7373

74-
assert.Equal(t, 1.0, sv.Min(),
74+
assert.InDelta(t, 1.0, sv.Min(), 1e-9,
7575
"Min should return the smallest value ever passed to Add")
76-
assert.Equal(t, 9.0, sv.Max(),
76+
assert.InDelta(t, 9.0, sv.Max(), 1e-9,
7777
"Max should return the largest value ever passed to Add")
7878
}
7979

@@ -152,7 +152,7 @@ func TestSpec_PublicAPI_Median_OddCount(t *testing.T) {
152152
sv.Add(1.0)
153153
sv.Add(2.0)
154154

155-
assert.Equal(t, 2.0, sv.Median(),
155+
assert.InDelta(t, 2.0, sv.Median(), 1e-9,
156156
"Median with odd count should return the middle value in sorted order")
157157
}
158158

@@ -167,6 +167,6 @@ func TestSpec_PublicAPI_Median_EvenCount(t *testing.T) {
167167
sv.Add(3.0)
168168
sv.Add(2.0)
169169

170-
assert.Equal(t, 2.5, sv.Median(),
170+
assert.InDelta(t, 2.5, sv.Median(), 1e-9,
171171
"Median with even count should return the average of the two middle sorted values")
172172
}

pkg/testutil/spec_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
1213

1314
"github.com/github/gh-aw/pkg/testutil"
1415
)
@@ -58,7 +59,7 @@ func TestSpec_PublicAPI_TempDir_CreatesSubdirectory(t *testing.T) {
5859
assert.NotEmpty(t, dir, "TempDir should return a non-empty path")
5960

6061
info, err := os.Stat(dir)
61-
assert.NoError(t, err, "TempDir should create an actual directory on disk")
62+
require.NoError(t, err, "TempDir should create an actual directory on disk")
6263
assert.True(t, info.IsDir(), "TempDir should create a directory, not a file")
6364

6465
runDir := testutil.GetTestRunDir()

0 commit comments

Comments
 (0)