From 132818033b686cefbbb9f4ec91940d2e3e371dfb Mon Sep 17 00:00:00 2001 From: Oleglacto Date: Mon, 24 Mar 2025 19:36:21 +0300 Subject: [PATCH] added `Do` method for raw query by single conn from `pool.Conn()` (#3182) * added `Do` method for raw query by single conn from `pool.Conn()` * added test to cmdble Do method * fixed test * moved Do cmd to commands.go --------- Co-authored-by: Oleg Laktyushkin Co-authored-by: Nedyalko Dyakov --- commands.go | 6 ++++++ commands_test.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/commands.go b/commands.go index d0085390..6321c15e 100644 --- a/commands.go +++ b/commands.go @@ -422,6 +422,12 @@ func (c cmdable) Ping(ctx context.Context) *StatusCmd { return cmd } +func (c cmdable) Do(ctx context.Context, args ...interface{}) *Cmd { + cmd := NewCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} + func (c cmdable) Quit(_ context.Context) *StatusCmd { panic("not implemented") } diff --git a/commands_test.go b/commands_test.go index a9e90fc9..55b95749 100644 --- a/commands_test.go +++ b/commands_test.go @@ -84,6 +84,12 @@ var _ = Describe("Commands", func() { Expect(ping.Val()).To(Equal("PONG")) }) + It("should Ping with Do method", func() { + result := client.Conn().Do(ctx, "PING") + Expect(result.Err()).NotTo(HaveOccurred()) + Expect(result.Val()).To(Equal("PONG")) + }) + It("should Wait", func() { const wait = 3 * time.Second