Skip to content

Commit 6551a20

Browse files
DOC-4331 made tests deterministic with sort
1 parent 20520dd commit 6551a20

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

doctests/query_ft_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package example_commands_test
55
import (
66
"context"
77
"fmt"
8+
"sort"
89

910
"github.com/redis/go-redis/v9"
1011
)
@@ -231,11 +232,15 @@ func ExampleClient_query_ft() {
231232

232233
fmt.Println(res1.Total) // >>> 2
233234

235+
sort.Slice(res1.Docs, func(i, j int) bool {
236+
return res1.Docs[i].ID < res1.Docs[j].ID
237+
})
238+
234239
for _, doc := range res1.Docs {
235240
fmt.Println(doc.ID)
236241
}
237-
// >>> bicycle:2
238242
// >>> bicycle:1
243+
// >>> bicycle:2
239244
// STEP_END
240245

241246
// STEP_START ft2
@@ -266,11 +271,14 @@ func ExampleClient_query_ft() {
266271

267272
fmt.Println(res3.Total) // >>> 2
268273

274+
sort.Slice(res3.Docs, func(i, j int) bool {
275+
return res3.Docs[i].ID < res3.Docs[j].ID
276+
})
269277
for _, doc := range res3.Docs {
270278
fmt.Println(doc.ID)
271279
}
272-
// >>> bicycle:6
273280
// >>> bicycle:4
281+
// >>> bicycle:6
274282
// STEP_END
275283

276284
// STEP_START ft4
@@ -309,13 +317,13 @@ func ExampleClient_query_ft() {
309317

310318
// Output:
311319
// 2
312-
// bicycle:2
313320
// bicycle:1
321+
// bicycle:2
314322
// 1
315323
// bicycle:4
316324
// 2
317-
// bicycle:6
318325
// bicycle:4
326+
// bicycle:6
319327
// 1
320328
// bicycle:3
321329
// 1

0 commit comments

Comments
 (0)