From e52e317d363a8d401dfd80c64794f63d14081cc9 Mon Sep 17 00:00:00 2001 From: Nathan Yergler Date: Thu, 19 Oct 2023 08:54:46 -0700 Subject: [PATCH] Add test for calling Ping in async mode Unfotunately it appears that calling t.Fatalf in defer doesn't stop the test, but it does display the error. --- async_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/async_test.go b/async_test.go index 3d976a052..a0715929a 100644 --- a/async_test.go +++ b/async_test.go @@ -45,6 +45,22 @@ func TestAsyncMode(t *testing.T) { }) } +func TestAsyncModePing(t *testing.T) { + ctx := WithAsyncMode(context.Background()) + + runDBTest(t, func(dbt *DBTest) { + defer func() { + if r := recover(); r != nil { + t.Fatalf("panic during ping: %v", r) + } + }() + err := dbt.conn.PingContext(ctx) + if err != nil { + t.Fatal(err) + } + }) +} + func TestAsyncModeMultiStatement(t *testing.T) { withMultiStmtCtx, _ := WithMultiStatement(context.Background(), 6) ctx := WithAsyncMode(withMultiStmtCtx)