Skip to content

Commit 6f811b5

Browse files
JimA-cyborgclaude
andcommitted
fixed linting errors
- err113: wrap two dynamic errors in concurrency_test.go with new static sentinels (errGetWrongItem, errVectorMismatch) - unparam: drop always-1e-5 rtol param from vectorsApproxEqual, use a const Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2c99bcf commit 6f811b5

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

test/concurrency_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const (
6363
var (
6464
errMissingID = errors.New("result missing ID")
6565
errNegativeDistance = errors.New("negative distance")
66+
errGetWrongItem = errors.New("get returned wrong item")
67+
errVectorMismatch = errors.New("retrieved vector mismatch")
6668
)
6769

6870
// ---------------------------------------------------------------------------
@@ -207,7 +209,7 @@ func TestConcurrentUpsertsOverlappingIDs(t *testing.T) {
207209
storedVec := item.GetVector()
208210
matched := false
209211
for _, c := range candidates {
210-
if vectorsApproxEqual(storedVec, c, 1e-5) {
212+
if vectorsApproxEqual(storedVec, c) {
211213
matched = true
212214
break
213215
}
@@ -952,7 +954,7 @@ func TestConcurrentWritesToDifferentIndexes(t *testing.T) {
952954
continue
953955
}
954956
retrievedVec := retrieved.Results[0].GetVector()
955-
if !vectorsApproxEqual(retrievedVec, data.vectors[checkIdx], 1e-5) {
957+
if !vectorsApproxEqual(retrievedVec, data.vectors[checkIdx]) {
956958
t.Errorf("Index '%s', ID '%s': vector mismatch — data routed to wrong index",
957959
data.name, data.ids[checkIdx])
958960
}
@@ -1112,13 +1114,13 @@ func TestConcurrentWriteThenVerifyPerThread(t *testing.T) {
11121114
}
11131115
if len(resp.Results) != 1 || resp.Results[0].GetId() != ids[0] {
11141116
mu.Lock()
1115-
errs = append(errs, fmt.Errorf("goroutine %d: get returned wrong item", gid))
1117+
errs = append(errs, fmt.Errorf("goroutine %d: %w", gid, errGetWrongItem))
11161118
mu.Unlock()
11171119
return
11181120
}
1119-
if !vectorsApproxEqual(resp.Results[0].GetVector(), vectors[0], 1e-5) {
1121+
if !vectorsApproxEqual(resp.Results[0].GetVector(), vectors[0]) {
11201122
mu.Lock()
1121-
errs = append(errs, fmt.Errorf("goroutine %d: retrieved vector mismatch", gid))
1123+
errs = append(errs, fmt.Errorf("goroutine %d: %w", gid, errVectorMismatch))
11221124
mu.Unlock()
11231125
}
11241126
}(g)
@@ -1278,7 +1280,7 @@ func TestRapidRoundRobinAcrossIndexes(t *testing.T) {
12781280
if gErr != nil {
12791281
t.Fatalf("get index %d: %v", i, gErr)
12801282
}
1281-
if len(got.Results) != 1 || !vectorsApproxEqual(got.Results[0].GetVector(), perIndexLastVecs[i][0], 1e-5) {
1283+
if len(got.Results) != 1 || !vectorsApproxEqual(got.Results[0].GetVector(), perIndexLastVecs[i][0]) {
12821284
t.Errorf("Index %d: last-round vector mismatch", i)
12831285
}
12841286
}

test/helpers_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ func generateRandomVectors(count, dimension int) [][]float32 {
138138
}
139139

140140
// vectorsApproxEqual checks if two float32 vectors are approximately equal.
141-
func vectorsApproxEqual(a, b []float32, rtol float64) bool {
141+
func vectorsApproxEqual(a, b []float32) bool {
142+
const rtol = 1e-5
142143
if len(a) != len(b) {
143144
return false
144145
}

0 commit comments

Comments
 (0)