From efe0f65bf0dde8b04d6a94c84f21a7b3cba56303 Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov Date: Mon, 20 Jan 2025 11:32:10 +0200 Subject: [PATCH] Order slices of strings to be sure what the output of Println in doctests will be. (#3241) * Sort the slices of strings in doctest to make the output deterministic * fix wording --- doctests/sets_example_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doctests/sets_example_test.go b/doctests/sets_example_test.go index 7446a278..2d6504e2 100644 --- a/doctests/sets_example_test.go +++ b/doctests/sets_example_test.go @@ -5,6 +5,7 @@ package example_commands_test import ( "context" "fmt" + "sort" "github.com/redis/go-redis/v9" ) @@ -215,6 +216,9 @@ func ExampleClient_saddsmembers() { panic(err) } + // Sort the strings in the slice to make sure the output is lexicographical + sort.Strings(res10) + fmt.Println(res10) // >>> [bike:1 bike:2 bike:3] // STEP_END @@ -294,6 +298,10 @@ func ExampleClient_sdiff() { panic(err) } + + // Sort the strings in the slice to make sure the output is lexicographical + sort.Strings(res13) + fmt.Println(res13) // >>> [bike:2 bike:3] // STEP_END @@ -349,6 +357,9 @@ func ExampleClient_multisets() { panic(err) } + // Sort the strings in the slice to make sure the output is lexicographical + 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() @@ -373,6 +384,9 @@ func ExampleClient_multisets() { panic(err) } + // Sort the strings in the slice to make sure the output is lexicographical + sort.Strings(res18) + fmt.Println(res18) // >>> [bike:2 bike:3] // STEP_END