Skip to content

Commit 7c08cb7

Browse files
committed
fix tests
1 parent 972950f commit 7c08cb7

File tree

1 file changed

+46
-36
lines changed

1 file changed

+46
-36
lines changed

search_test.go

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,14 +3407,16 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
34073407
Expect(rawValResults[0]).To(Or(BeEquivalentTo(results[0]), BeEquivalentTo(results[1])))
34083408
Expect(rawValResults[1]).To(Or(BeEquivalentTo(results[0]), BeEquivalentTo(results[1])))
34093409

3410-
// Test with UnstableResp3 false
3411-
Expect(func() {
3412-
options = &redis.FTAggregateOptions{Apply: []redis.FTAggregateApply{{Field: "@CreatedDateTimeUTC * 10", As: "CreatedDateTimeUTC"}}}
3413-
rawRes, _ := client2.FTAggregateWithArgs(ctx, "idx1", "*", options).RawResult()
3414-
rawVal = client2.FTAggregateWithArgs(ctx, "idx1", "*", options).RawVal()
3415-
Expect(rawRes).To(BeNil())
3416-
Expect(rawVal).To(BeNil())
3417-
}).Should(Panic())
3410+
// Test with UnstableResp3 false - should return error instead of panic
3411+
options = &redis.FTAggregateOptions{Apply: []redis.FTAggregateApply{{Field: "@CreatedDateTimeUTC * 10", As: "CreatedDateTimeUTC"}}}
3412+
rawRes, err := client2.FTAggregateWithArgs(ctx, "idx1", "*", options).RawResult()
3413+
Expect(err).To(HaveOccurred())
3414+
Expect(err.Error()).To(ContainSubstring("RESP3 responses for this command are disabled"))
3415+
Expect(rawRes).To(BeNil())
3416+
3417+
rawVal = client2.FTAggregateWithArgs(ctx, "idx1", "*", options).RawVal()
3418+
Expect(client2.FTAggregateWithArgs(ctx, "idx1", "*", options).Err()).To(HaveOccurred())
3419+
Expect(rawVal).To(BeNil())
34183420

34193421
})
34203422

@@ -3435,13 +3437,15 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
34353437
flags = attributes[0].(map[interface{}]interface{})["flags"].([]interface{})
34363438
Expect(flags).To(ConsistOf("SORTABLE", "NOSTEM"))
34373439

3438-
// Test with UnstableResp3 false
3439-
Expect(func() {
3440-
rawResInfo, _ := client2.FTInfo(ctx, "idx1").RawResult()
3441-
rawValInfo := client2.FTInfo(ctx, "idx1").RawVal()
3442-
Expect(rawResInfo).To(BeNil())
3443-
Expect(rawValInfo).To(BeNil())
3444-
}).Should(Panic())
3440+
// Test with UnstableResp3 false - should return error instead of panic
3441+
rawResInfo, err := client2.FTInfo(ctx, "idx1").RawResult()
3442+
Expect(err).To(HaveOccurred())
3443+
Expect(err.Error()).To(ContainSubstring("RESP3 responses for this command are disabled"))
3444+
Expect(rawResInfo).To(BeNil())
3445+
3446+
rawValInfo := client2.FTInfo(ctx, "idx1").RawVal()
3447+
Expect(client2.FTInfo(ctx, "idx1").Err()).To(HaveOccurred())
3448+
Expect(rawValInfo).To(BeNil())
34453449
})
34463450

34473451
It("should handle FTSpellCheck with Unstable RESP3 Search Module and without stability", Label("search", "ftcreate", "ftspellcheck"), func() {
@@ -3462,13 +3466,15 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
34623466
results := resSpellCheck.(map[interface{}]interface{})["results"].(map[interface{}]interface{})
34633467
Expect(results["impornant"].([]interface{})[0].(map[interface{}]interface{})["important"]).To(BeEquivalentTo(0.5))
34643468

3465-
// Test with UnstableResp3 false
3466-
Expect(func() {
3467-
rawResSpellCheck, _ := client2.FTSpellCheck(ctx, "idx1", "impornant").RawResult()
3468-
rawValSpellCheck := client2.FTSpellCheck(ctx, "idx1", "impornant").RawVal()
3469-
Expect(rawResSpellCheck).To(BeNil())
3470-
Expect(rawValSpellCheck).To(BeNil())
3471-
}).Should(Panic())
3469+
// Test with UnstableResp3 false - should return error instead of panic
3470+
rawResSpellCheck, err := client2.FTSpellCheck(ctx, "idx1", "impornant").RawResult()
3471+
Expect(err).To(HaveOccurred())
3472+
Expect(err.Error()).To(ContainSubstring("RESP3 responses for this command are disabled"))
3473+
Expect(rawResSpellCheck).To(BeNil())
3474+
3475+
rawValSpellCheck := client2.FTSpellCheck(ctx, "idx1", "impornant").RawVal()
3476+
Expect(client2.FTSpellCheck(ctx, "idx1", "impornant").Err()).To(HaveOccurred())
3477+
Expect(rawValSpellCheck).To(BeNil())
34723478
})
34733479

34743480
It("should handle FTSearch with Unstable RESP3 Search Module and without stability", Label("search", "ftcreate", "ftsearch"), func() {
@@ -3489,13 +3495,15 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
34893495
totalResults2 := res2.(map[interface{}]interface{})["total_results"]
34903496
Expect(totalResults2).To(BeEquivalentTo(int64(1)))
34913497

3492-
// Test with UnstableResp3 false
3493-
Expect(func() {
3494-
rawRes2, _ := client2.FTSearchWithArgs(ctx, "txt", "foo bar hello world", &redis.FTSearchOptions{NoContent: true}).RawResult()
3495-
rawVal2 := client2.FTSearchWithArgs(ctx, "txt", "foo bar hello world", &redis.FTSearchOptions{NoContent: true}).RawVal()
3496-
Expect(rawRes2).To(BeNil())
3497-
Expect(rawVal2).To(BeNil())
3498-
}).Should(Panic())
3498+
// Test with UnstableResp3 false - should return error instead of panic
3499+
rawRes2, err := client2.FTSearchWithArgs(ctx, "txt", "foo bar hello world", &redis.FTSearchOptions{NoContent: true}).RawResult()
3500+
Expect(err).To(HaveOccurred())
3501+
Expect(err.Error()).To(ContainSubstring("RESP3 responses for this command are disabled"))
3502+
Expect(rawRes2).To(BeNil())
3503+
3504+
rawVal2 := client2.FTSearchWithArgs(ctx, "txt", "foo bar hello world", &redis.FTSearchOptions{NoContent: true}).RawVal()
3505+
Expect(client2.FTSearchWithArgs(ctx, "txt", "foo bar hello world", &redis.FTSearchOptions{NoContent: true}).Err()).To(HaveOccurred())
3506+
Expect(rawVal2).To(BeNil())
34993507
})
35003508
It("should handle FTSynDump with Unstable RESP3 Search Module and without stability", Label("search", "ftsyndump"), func() {
35013509
text1 := &redis.FieldSchema{FieldName: "title", FieldType: redis.SearchFieldTypeText}
@@ -3523,13 +3531,15 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
35233531
Expect(valSynDump).To(BeEquivalentTo(resSynDump))
35243532
Expect(resSynDump.(map[interface{}]interface{})["baby"]).To(BeEquivalentTo([]interface{}{"id1"}))
35253533

3526-
// Test with UnstableResp3 false
3527-
Expect(func() {
3528-
rawResSynDump, _ := client2.FTSynDump(ctx, "idx1").RawResult()
3529-
rawValSynDump := client2.FTSynDump(ctx, "idx1").RawVal()
3530-
Expect(rawResSynDump).To(BeNil())
3531-
Expect(rawValSynDump).To(BeNil())
3532-
}).Should(Panic())
3534+
// Test with UnstableResp3 false - should return error instead of panic
3535+
rawResSynDump, err := client2.FTSynDump(ctx, "idx1").RawResult()
3536+
Expect(err).To(HaveOccurred())
3537+
Expect(err.Error()).To(ContainSubstring("RESP3 responses for this command are disabled"))
3538+
Expect(rawResSynDump).To(BeNil())
3539+
3540+
rawValSynDump := client2.FTSynDump(ctx, "idx1").RawVal()
3541+
Expect(client2.FTSynDump(ctx, "idx1").Err()).To(HaveOccurred())
3542+
Expect(rawValSynDump).To(BeNil())
35333543
})
35343544

35353545
It("should test not affected Resp 3 Search method - FTExplain", Label("search", "ftexplain"), func() {

0 commit comments

Comments
 (0)