Skip to content

Commit

Permalink
feat: cover some more conditions in adapter.go
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulPancake committed Jun 28, 2024
1 parent be94a8d commit aa8fc77
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions rueidiscompat/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8943,6 +8943,10 @@ func testAdapterCache(resp3 bool) {
resultAdd, err = adapter.TFunctionLoadArgs(ctx, libCodeWithConfig("lib1"), opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
opt.Replace = false
resultAdd, err = adapter.TFunctionLoadArgs(ctx, libCodeWithConfig("lib2"), opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
})
It("should TFunctionList", Label("gears", "tfunctionlist"), func() {
resultAdd, err := adapter.TFunctionLoad(ctx, libCode("lib1")).Result()
Expand All @@ -8955,6 +8959,10 @@ func testAdapterCache(resp3 bool) {
resultListArgs, err := adapter.TFunctionListArgs(ctx, opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultListArgs[0]["code"]).NotTo(BeEquivalentTo(""))
opt.Library = "VERBOSE"
resultListArgs, err = adapter.TFunctionListArgs(ctx, opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultListArgs[0]["code"]).NotTo(BeEquivalentTo(""))
})

It("should TFCall", Label("gears", "tfcall"), func() {
Expand Down Expand Up @@ -9165,6 +9173,21 @@ func testAdapterCache(resp3 bool) {
Expect(result).To(BeAssignableToTypeOf(BFInfo{}))
Expect(result.Capacity).To(BeEquivalentTo(int64(2000)))
Expect(result.ExpansionRate).To(BeEquivalentTo(int64(3)))

options.NonScaling = true
resultInsert, err = adapter.BFInsert(ctx, "testbf2", options, "item1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(len(resultInsert)).To(BeEquivalentTo(1))

exists, err = adapter.BFExists(ctx, "testbf2", "item1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(exists).To(BeTrue())

result, err = adapter.BFInfo(ctx, "testbf2").Result()
Expect(err).NotTo(HaveOccurred())
Expect(result).To(BeAssignableToTypeOf(BFInfo{}))
Expect(result.Capacity).To(BeEquivalentTo(int64(2000)))
Expect(result.ExpansionRate).To(BeEquivalentTo(int64(0)))
})

It("should BFMAdd", Label("bloom", "bfmadd"), func() {
Expand Down Expand Up @@ -9265,6 +9288,10 @@ func testAdapterCache(resp3 bool) {
Expect(result).To(BeAssignableToTypeOf(BFInfo{}))
Expect(result.Capacity).To(BeEquivalentTo(int64(2000)))
Expect(result.ExpansionRate).To(BeEquivalentTo(int64(3)))

options.NonScaling = true
err = adapter.BFReserveWithArgs(ctx, "testbf2", options).Err()
Expect(err).To(HaveOccurred())
})
})

Expand Down Expand Up @@ -9751,6 +9778,19 @@ func testAdapterCache(resp3 bool) {
max, err := adapter.TDigestMax(ctx, "tdigest1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(max).To(BeEquivalentTo(float64(140)))

options.Override = true
err = adapter.TDigestMerge(ctx, "tdigest1", options, "tdigest2", "tdigest3").Err()
Expect(err).NotTo(HaveOccurred())

info, err = adapter.TDigestInfo(ctx, "tdigest1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(info.Observations).To(BeEquivalentTo(int64(20)))
Expect(info.Compression).To(BeEquivalentTo(int64(1000)))

max, err = adapter.TDigestMax(ctx, "tdigest1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(max).To(BeEquivalentTo(float64(140)))
})
})
})
Expand Down

0 comments on commit aa8fc77

Please sign in to comment.