From ff37dc2711a877451f644f99a4971a090b8eee11 Mon Sep 17 00:00:00 2001 From: Craig Pastro <28915792+craigpastro@users.noreply.github.com> Date: Thu, 8 Aug 2024 07:21:28 -0700 Subject: [PATCH] Expose Ping (#51) --- pgmq.go | 5 +++++ pgmq_test.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pgmq.go b/pgmq.go index 67df61d..84fa62d 100644 --- a/pgmq.go +++ b/pgmq.go @@ -78,6 +78,11 @@ func (p *PGMQ) Close() { p.db.Close() } +// Ping calls the underlying Ping function of the DB interface. +func (p *PGMQ) Ping(ctx context.Context) error { + return p.db.Ping(ctx) +} + // CreateQueue creates a new queue. This sets up the queue's tables, indexes, // and metadata. func (p *PGMQ) CreateQueue(ctx context.Context, queue string) error { diff --git a/pgmq_test.go b/pgmq_test.go index e9899fe..3e97d9f 100644 --- a/pgmq_test.go +++ b/pgmq_test.go @@ -70,6 +70,11 @@ func TestMain(m *testing.M) { os.Exit(code) } +func TestPing(t *testing.T) { + err := q.Ping(context.Background()) + require.NoError(t, err) +} + func TestCreateAndDropQueue(t *testing.T) { ctx := context.Background() queue := t.Name()