Skip to content

Commit

Permalink
Sort the slices of strings in doctest to make the output deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
ndyakov committed Jan 17, 2025
1 parent 0e3ea5f commit 070e63c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doctests/sets_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package example_commands_test
import (
"context"
"fmt"
"sort"

"github.com/redis/go-redis/v9"
)
Expand Down Expand Up @@ -215,6 +216,8 @@ func ExampleClient_saddsmembers() {
panic(err)
}

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

Expand Down Expand Up @@ -294,6 +297,10 @@ func ExampleClient_sdiff() {
panic(err)
}


// Sort the strings in the slice to make sure the output is alphabetical
sort.Strings(res13)

fmt.Println(res13) // >>> [bike:2 bike:3]
// STEP_END

Expand Down Expand Up @@ -349,6 +356,9 @@ func ExampleClient_multisets() {
panic(err)
}

// Sort the strings in the slice to make sure the output is alphabetical
sort.Strings(res15)

fmt.Println(res15) // >>> [bike:1 bike:2 bike:3 bike:4]

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

// Sort the strings in the slice to make sure the output is alphabetical
sort.Strings(res18)

fmt.Println(res18) // >>> [bike:2 bike:3]
// STEP_END

Expand Down

0 comments on commit 070e63c

Please sign in to comment.