From 3020e5437c2d92d55a847a30132679a78c0992ce Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov Date: Tue, 4 Mar 2025 14:03:33 +0200 Subject: [PATCH] fix(test): sort results in example test by sorting the results that we would like to get from redis we make sure the exampele test passes. p.s. we are sorting by price but there are items with identical prices the data itself may need to change a bit. Let's see if we experience any flakiness with this setup. --- doctests/query_range_test.go | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/doctests/query_range_test.go b/doctests/query_range_test.go index 41438ff0e..09b3bb619 100644 --- a/doctests/query_range_test.go +++ b/doctests/query_range_test.go @@ -230,6 +230,12 @@ func ExampleClient_query_range() { FieldName: "price", }, }, + SortBy: []redis.FTSearchSortBy{ + { + FieldName: "price", + Asc: true, + }, + }, }, ).Result() @@ -263,6 +269,12 @@ func ExampleClient_query_range() { FieldName: "price", }, }, + SortBy: []redis.FTSearchSortBy{ + { + FieldName: "price", + Asc: true, + }, + }, }, ).Result() @@ -289,6 +301,12 @@ func ExampleClient_query_range() { FieldName: "price", }, }, + SortBy: []redis.FTSearchSortBy{ + { + FieldName: "price", + Asc: true, + }, + }, Filters: []redis.FTSearchFilter{ { FieldName: "price", @@ -354,19 +372,19 @@ func ExampleClient_query_range() { // Output: // 3 - // bicycle:2 : price 815 // bicycle:5 : price 810 + // bicycle:2 : price 815 // bicycle:9 : price 815 // 3 - // bicycle:2 : price 815 // bicycle:5 : price 810 + // bicycle:2 : price 815 // bicycle:9 : price 815 // 5 // bicycle:1 : price 1200 - // bicycle:4 : price 3200 + // bicycle:8 : price 1200 // bicycle:6 : price 2300 + // bicycle:4 : price 3200 // bicycle:3 : price 3400 - // bicycle:8 : price 1200 // 7 // bicycle:0 : price 270 // bicycle:7 : price 430