From 070e63ccd3656882fc326f22ddee2640557f96c2 Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov Date: Fri, 17 Jan 2025 17:31:51 +0200 Subject: [PATCH 1/2] Sort the slices of strings in doctest to make the output deterministic --- doctests/sets_example_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doctests/sets_example_test.go b/doctests/sets_example_test.go index 7446a2789..6130e508e 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,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 @@ -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 @@ -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() @@ -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 From 69393fc8cc892ce7c271f903cf22ef041341ea56 Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov Date: Fri, 17 Jan 2025 17:37:40 +0200 Subject: [PATCH 2/2] fix wording --- doctests/sets_example_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doctests/sets_example_test.go b/doctests/sets_example_test.go index 6130e508e..2d6504e2b 100644 --- a/doctests/sets_example_test.go +++ b/doctests/sets_example_test.go @@ -216,8 +216,9 @@ func ExampleClient_saddsmembers() { panic(err) } - // Sort the strings in the slice to make sure the output is alphabetical + // 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 @@ -298,7 +299,7 @@ func ExampleClient_sdiff() { } - // Sort the strings in the slice to make sure the output is alphabetical + // Sort the strings in the slice to make sure the output is lexicographical sort.Strings(res13) fmt.Println(res13) // >>> [bike:2 bike:3] @@ -356,7 +357,7 @@ func ExampleClient_multisets() { panic(err) } - // Sort the strings in the slice to make sure the output is alphabetical + // 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] @@ -383,7 +384,7 @@ func ExampleClient_multisets() { panic(err) } - // Sort the strings in the slice to make sure the output is alphabetical + // Sort the strings in the slice to make sure the output is lexicographical sort.Strings(res18) fmt.Println(res18) // >>> [bike:2 bike:3]