Skip to content

Commit 070e63c

Browse files
committed
Sort the slices of strings in doctest to make the output deterministic
1 parent 0e3ea5f commit 070e63c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doctests/sets_example_test.go

Lines changed: 13 additions & 0 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
)
@@ -215,6 +216,8 @@ func ExampleClient_saddsmembers() {
215216
panic(err)
216217
}
217218

219+
// Sort the strings in the slice to make sure the output is alphabetical
220+
sort.Strings(res10)
218221
fmt.Println(res10) // >>> [bike:1 bike:2 bike:3]
219222
// STEP_END
220223

@@ -294,6 +297,10 @@ func ExampleClient_sdiff() {
294297
panic(err)
295298
}
296299

300+
301+
// Sort the strings in the slice to make sure the output is alphabetical
302+
sort.Strings(res13)
303+
297304
fmt.Println(res13) // >>> [bike:2 bike:3]
298305
// STEP_END
299306

@@ -349,6 +356,9 @@ func ExampleClient_multisets() {
349356
panic(err)
350357
}
351358

359+
// Sort the strings in the slice to make sure the output is alphabetical
360+
sort.Strings(res15)
361+
352362
fmt.Println(res15) // >>> [bike:1 bike:2 bike:3 bike:4]
353363

354364
res16, err := rdb.SDiff(ctx, "bikes:racing:france", "bikes:racing:usa", "bikes:racing:italy").Result()
@@ -373,6 +383,9 @@ func ExampleClient_multisets() {
373383
panic(err)
374384
}
375385

386+
// Sort the strings in the slice to make sure the output is alphabetical
387+
sort.Strings(res18)
388+
376389
fmt.Println(res18) // >>> [bike:2 bike:3]
377390
// STEP_END
378391

0 commit comments

Comments
 (0)