fixing tests

This commit is contained in:
ofekshenawa 2023-11-17 01:12:51 +02:00
parent 66295d8299
commit 5ae0c0679a
1 changed files with 6 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package redis_test
import ( import (
"context" "context"
"time"
. "github.com/bsm/ginkgo/v2" . "github.com/bsm/ginkgo/v2"
. "github.com/bsm/gomega" . "github.com/bsm/gomega"
@ -374,12 +375,12 @@ var _ = Describe("RediSearch commands", Label("search"), func() {
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "TFIDF.DOCNORM"}).Result() res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "TFIDF.DOCNORM"}).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
result = res.(map[interface{}]interface{})["results"].([]interface{})[0].(map[interface{}]interface{})["score"] result = res.(map[interface{}]interface{})["results"].([]interface{})[0].(map[interface{}]interface{})["score"]
Expect(result).To(BeEquivalentTo(0.1111111111111111)) Expect(result).To(BeEquivalentTo(0.14285714285714285))
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "BM25"}).Result() res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "BM25"}).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
result = res.(map[interface{}]interface{})["results"].([]interface{})[0].(map[interface{}]interface{})["score"] result = res.(map[interface{}]interface{})["results"].([]interface{})[0].(map[interface{}]interface{})["score"]
Expect(result).To(BeEquivalentTo(0.17699114465425977)) Expect(result).To(BeEquivalentTo(0.22471909420069797))
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "DISMAX"}).Result() res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "DISMAX"}).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
@ -722,7 +723,7 @@ var _ = Describe("RediSearch commands", Label("search"), func() {
val, err = client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, tag2).Result() val, err = client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, tag2).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(val).To(BeEquivalentTo("OK")) Expect(val).To(BeEquivalentTo("OK"))
time.Sleep(5 * time.Second)
res, err = client.FTSearch(ctx, "idx1", "@t:{HELLO}").Result() res, err = client.FTSearch(ctx, "idx1", "@t:{HELLO}").Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
results = res.(map[interface{}]interface{})["results"].([]interface{}) results = res.(map[interface{}]interface{})["results"].([]interface{})
@ -743,6 +744,8 @@ var _ = Describe("RediSearch commands", Label("search"), func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(val).To(BeEquivalentTo("OK")) Expect(val).To(BeEquivalentTo("OK"))
time.Sleep(5 * time.Second)
res, err := client.FTSearchWithArgs(ctx, "idx1", "*", &redis.FTSearchOptions{Return: []redis.FTSearchReturn{{FieldName: "$.t", As: "txt"}}}).Result() res, err := client.FTSearchWithArgs(ctx, "idx1", "*", &redis.FTSearchOptions{Return: []redis.FTSearchReturn{{FieldName: "$.t", As: "txt"}}}).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
results := res.(map[interface{}]interface{})["results"].([]interface{}) results := res.(map[interface{}]interface{})["results"].([]interface{})