From 510a5b7efe3f8d9c6045105faed6c054dedb5042 Mon Sep 17 00:00:00 2001 From: evgeniy-scherbina Date: Wed, 19 Feb 2025 16:05:09 -0500 Subject: [PATCH 1/2] fix(coderd/database): remove linux build tags from db package --- coderd/database/db_test.go | 2 -- coderd/database/dbtestutil/postgres_test.go | 2 -- coderd/database/migrations/migrate_test.go | 2 -- coderd/database/pubsub/pubsub_linux_test.go | 2 -- coderd/database/querier_test.go | 2 -- 5 files changed, 10 deletions(-) diff --git a/coderd/database/db_test.go b/coderd/database/db_test.go index b4580527c843a..68b60a788fd3d 100644 --- a/coderd/database/db_test.go +++ b/coderd/database/db_test.go @@ -1,5 +1,3 @@ -//go:build linux - package database_test import ( diff --git a/coderd/database/dbtestutil/postgres_test.go b/coderd/database/dbtestutil/postgres_test.go index d4aaacdf909d8..49e791a4c735e 100644 --- a/coderd/database/dbtestutil/postgres_test.go +++ b/coderd/database/dbtestutil/postgres_test.go @@ -1,5 +1,3 @@ -//go:build linux - package dbtestutil_test import ( diff --git a/coderd/database/migrations/migrate_test.go b/coderd/database/migrations/migrate_test.go index 716ebe398b6d7..bd347af0be1ea 100644 --- a/coderd/database/migrations/migrate_test.go +++ b/coderd/database/migrations/migrate_test.go @@ -1,5 +1,3 @@ -//go:build linux - package migrations_test import ( diff --git a/coderd/database/pubsub/pubsub_linux_test.go b/coderd/database/pubsub/pubsub_linux_test.go index fe7933c62caee..05bd76232e162 100644 --- a/coderd/database/pubsub/pubsub_linux_test.go +++ b/coderd/database/pubsub/pubsub_linux_test.go @@ -1,5 +1,3 @@ -//go:build linux - package pubsub_test import ( diff --git a/coderd/database/querier_test.go b/coderd/database/querier_test.go index 00b189967f5a6..2897a88b880ff 100644 --- a/coderd/database/querier_test.go +++ b/coderd/database/querier_test.go @@ -1,5 +1,3 @@ -//go:build linux - package database_test import ( From 01d399bddd1d286c9423b0424a8f94914542b1c4 Mon Sep 17 00:00:00 2001 From: evgeniy-scherbina Date: Tue, 25 Feb 2025 11:13:31 -0500 Subject: [PATCH 2/2] test(coderd/database): skip tests when PostgreSQL is unavailable --- coderd/database/dbtestutil/postgres_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/coderd/database/dbtestutil/postgres_test.go b/coderd/database/dbtestutil/postgres_test.go index 49e791a4c735e..f1b9336d57b37 100644 --- a/coderd/database/dbtestutil/postgres_test.go +++ b/coderd/database/dbtestutil/postgres_test.go @@ -19,6 +19,9 @@ func TestMain(m *testing.M) { func TestOpen(t *testing.T) { t.Parallel() + if !dbtestutil.WillUsePostgres() { + t.Skip("this test requires postgres") + } connect, err := dbtestutil.Open(t) require.NoError(t, err) @@ -33,6 +36,9 @@ func TestOpen(t *testing.T) { func TestOpen_InvalidDBFrom(t *testing.T) { t.Parallel() + if !dbtestutil.WillUsePostgres() { + t.Skip("this test requires postgres") + } _, err := dbtestutil.Open(t, dbtestutil.WithDBFrom("__invalid__")) require.Error(t, err) @@ -42,6 +48,9 @@ func TestOpen_InvalidDBFrom(t *testing.T) { func TestOpen_ValidDBFrom(t *testing.T) { t.Parallel() + if !dbtestutil.WillUsePostgres() { + t.Skip("this test requires postgres") + } // first check if we can create a new template db dsn, err := dbtestutil.Open(t, dbtestutil.WithDBFrom(""))