Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: remove references to dbtestutil.WillUsePostgres#20436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugodutka merged 3 commits intomainfromremove-willusepostgres
Oct 23, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletionscli/delete_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -185,9 +185,6 @@ func TestDelete(t *testing.T) {

t.Run("WarnNoProvisioners", func(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}

store, ps, db := dbtestutil.NewDBWithSQLDB(t)
client, closeDaemon := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{
Expand DownExpand Up@@ -228,9 +225,6 @@ func TestDelete(t *testing.T) {

t.Run("Prebuilt workspace delete permissions", func(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}

// Setup
db, pb := dbtestutil.NewDB(t, dbtestutil.WithDumpOnFailure())
Expand Down
3 changes: 0 additions & 3 deletionscli/server_regenerate_vapid_keypair_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,9 +17,6 @@ import (

func TestRegenerateVapidKeypair(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("this test is only supported on postgres")
}

t.Run("NoExistingVAPIDKeys", func(t *testing.T) {
t.Parallel()
Expand Down
11 changes: 0 additions & 11 deletionscli/server_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,9 +348,6 @@ func TestServer(t *testing.T) {

runGitHubProviderTest := func(t *testing.T, tc testCase) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("test requires postgres")
}

ctx, cancelFunc := context.WithCancel(testutil.Context(t, testutil.WaitLong))
defer cancelFunc()
Expand DownExpand Up@@ -2142,10 +2139,6 @@ func TestServerYAMLConfig(t *testing.T) {
func TestConnectToPostgres(t *testing.T) {
t.Parallel()

if !dbtestutil.WillUsePostgres() {
t.Skip("this test does not make sense without postgres")
}

t.Run("Migrate", func(t *testing.T) {
t.Parallel()

Expand DownExpand Up@@ -2256,10 +2249,6 @@ type runServerOpts struct {
func TestServer_TelemetryDisabled_FinalReport(t *testing.T) {
t.Parallel()

if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}

telemetryServerURL, deployment, snapshot := mockTelemetryServer(t)
dbConnURL, err := dbtestutil.Open(t)
require.NoError(t, err)
Expand Down
5 changes: 0 additions & 5 deletionscoderd/aitasks_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,6 @@ import (
"github.com/coder/coder/v2/coderd/database/dbauthz"
"github.com/coder/coder/v2/coderd/database/dbfake"
"github.com/coder/coder/v2/coderd/database/dbgen"
"github.com/coder/coder/v2/coderd/database/dbtestutil"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/notifications"
"github.com/coder/coder/v2/coderd/notifications/notificationstest"
Expand DownExpand Up@@ -54,10 +53,6 @@ func TestAITasksPrompts(t *testing.T) {
t.Run("MultipleBuilds", func(t *testing.T) {
t.Parallel()

if !dbtestutil.WillUsePostgres() {
t.Skip("This test checks RBAC, which is not supported in the in-memory database")
}

adminClient := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
first := coderdtest.CreateFirstUser(t, adminClient)
memberClient, _ := coderdtest.CreateAnotherUser(t, adminClient, first.OrganizationID)
Expand Down
8 changes: 0 additions & 8 deletionscoderd/autobuild/lifecycle_executor_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -776,10 +776,6 @@ func TestExecutorWorkspaceAutostopNoWaitChangedMyMind(t *testing.T) {
}

func TestExecutorAutostartMultipleOK(t *testing.T) {
if !dbtestutil.WillUsePostgres() {
t.Skip(`This test only really works when using a "real" database, similar to a HA setup`)
}

t.Parallel()

var (
Expand DownExpand Up@@ -1259,10 +1255,6 @@ func TestNotifications(t *testing.T) {
func TestExecutorPrebuilds(t *testing.T) {
t.Parallel()

if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}

// Prebuild workspaces should not be autostopped when the deadline is reached.
// After being claimed, the workspace should stop at the deadline.
t.Run("OnlyStopsAfterClaimed", func(t *testing.T) {
Expand Down
4 changes: 0 additions & 4 deletionscoderd/database/db_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,10 +85,6 @@ func TestNestedInTx(t *testing.T) {
func testSQLDB(t testing.TB) *sql.DB {
t.Helper()

if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}

connection, err := dbtestutil.Open(t)
require.NoError(t, err)

Expand Down
3 changes: 1 addition & 2 deletionscoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2946,7 +2946,6 @@ func (s *MethodTestSuite) TestSystemFunctions() {
dbm.EXPECT().GetParameterSchemasByJobID(gomock.Any(), jobID).Return([]database.ParameterSchema{}, nil).AnyTimes()
check.Args(jobID).
Asserts(tpl, policy.ActionRead).
ErrorsWithInMemDB(sql.ErrNoRows).
Returns([]database.ParameterSchema{})
}))
s.Run("GetWorkspaceAppsByAgentIDs", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
Expand DownExpand Up@@ -3189,7 +3188,7 @@ func (s *MethodTestSuite) TestSystemFunctions() {
}))
s.Run("GetAppSecurityKey", s.Mocked(func(dbm *dbmock.MockStore, _ *gofakeit.Faker, check *expects) {
dbm.EXPECT().GetAppSecurityKey(gomock.Any()).Return("", sql.ErrNoRows).AnyTimes()
check.Args().Asserts(rbac.ResourceSystem, policy.ActionRead).ErrorsWithPG(sql.ErrNoRows)
check.Args().Asserts(rbac.ResourceSystem, policy.ActionRead).Errors(sql.ErrNoRows)
}))
s.Run("UpsertAppSecurityKey", s.Mocked(func(dbm *dbmock.MockStore, _ *gofakeit.Faker, check *expects) {
dbm.EXPECT().UpsertAppSecurityKey(gomock.Any(), "foo").Return(nil).AnyTimes()
Expand Down
18 changes: 0 additions & 18 deletionscoderd/database/dbauthz/setup_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -430,24 +430,6 @@ func (m *expects) Errors(err error) *expects {
return m
}

// ErrorsWithPG is optional. If it is never called, it will not be asserted.
// It will only be asserted if the test is running with a Postgres database.
func (m *expects) ErrorsWithPG(err error) *expects {
if dbtestutil.WillUsePostgres() {
return m.Errors(err)
}
return m
}

// ErrorsWithInMemDB is optional. If it is never called, it will not be asserted.
// It will only be asserted if the test is running with an in-memory database.
func (m *expects) ErrorsWithInMemDB(err error) *expects {
if !dbtestutil.WillUsePostgres() {
return m.Errors(err)
}
return m
}

func (m *expects) FailSystemObjectChecks() *expects {
return m.WithSuccessAuthorizer(func(ctx context.Context, subject rbac.Subject, action policy.Action, obj rbac.Object) error {
if obj.Type == rbac.ResourceSystem.Type {
Expand Down
4 changes: 0 additions & 4 deletionscoderd/database/dbrollup/dbrollup_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,10 +52,6 @@ func (w *wrapUpsertDB) UpsertTemplateUsageStats(ctx context.Context) error {
func TestRollup_TwoInstancesUseLocking(t *testing.T) {
t.Parallel()

if !dbtestutil.WillUsePostgres() {
t.Skip("Skipping test; only works with PostgreSQL.")
}

db, ps := dbtestutil.NewDB(t, dbtestutil.WithDumpOnFailure())
logger := testutil.Logger(t)

Expand Down
11 changes: 0 additions & 11 deletionscoderd/database/dbtestutil/db.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,13 +23,6 @@ import (
"github.com/coder/coder/v2/testutil"
)

// WillUsePostgres returns true if a call to NewDB() will return a real, postgres-backed Store and Pubsub.
// TODO(hugodutka): since we removed the in-memory database, this is always true,
// and we need to remove this function. https://github.com/coder/internal/issues/758
func WillUsePostgres() bool {
return true
}

type options struct {
fixedTimezone string
dumpOnFailure bool
Expand DownExpand Up@@ -75,10 +68,6 @@ func withReturnSQLDB(f func(*sql.DB)) Option {
func NewDBWithSQLDB(t testing.TB, opts ...Option) (database.Store, pubsub.Pubsub, *sql.DB) {
t.Helper()

if !WillUsePostgres() {
t.Fatal("cannot use NewDBWithSQLDB without PostgreSQL, consider adding `if !dbtestutil.WillUsePostgres() { t.Skip() }` to this test")
}

var sqlDB *sql.DB
opts = append(opts, withReturnSQLDB(func(db *sql.DB) {
sqlDB = db
Expand Down
15 changes: 0 additions & 15 deletionscoderd/database/dbtestutil/postgres_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,9 +20,6 @@ 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)
Expand All@@ -37,9 +34,6 @@ 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)
Expand All@@ -49,9 +43,6 @@ 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(""))
Expand DownExpand Up@@ -115,9 +106,6 @@ func TestOpen_ValidDBFrom(t *testing.T) {
func TestOpen_Panic(t *testing.T) {
t.Skip("unskip this to manually test that we don't leak a database into postgres")
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}

_, err := dbtestutil.Open(t)
require.NoError(t, err)
Expand All@@ -127,9 +115,6 @@ func TestOpen_Panic(t *testing.T) {
func TestOpen_Timeout(t *testing.T) {
t.Skip("unskip this and set a short timeout to manually test that we don't leak a database into postgres")
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}

_, err := dbtestutil.Open(t)
require.NoError(t, err)
Expand Down
6 changes: 0 additions & 6 deletionscoderd/database/pubsub/pubsub_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,6 @@ import (

func TestPGPubsub_Metrics(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("test only with postgres")
}

logger := testutil.Logger(t)
connectionURL, err := dbtestutil.Open(t)
Expand DownExpand Up@@ -122,9 +119,6 @@ func TestPGPubsub_Metrics(t *testing.T) {

func TestPGPubsubDriver(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("test only with postgres")
}

ctx := testutil.Context(t, testutil.WaitLong)
logger := slogtest.Make(t, &slogtest.Options{
Expand Down
28 changes: 0 additions & 28 deletionscoderd/database/querier_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3742,9 +3742,6 @@ func TestGetProvisionerJobsByIDsWithQueuePosition(t *testing.T) {

func TestGetProvisionerJobsByIDsWithQueuePosition_MixedStatuses(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.SkipNow()
}

db, _ := dbtestutil.NewDB(t)
now := dbtime.Now()
Expand DownExpand Up@@ -4084,10 +4081,6 @@ func TestGetUserStatusCounts(t *testing.T) {
t.Parallel()
t.Skip("https://github.com/coder/internal/issues/464")

if !dbtestutil.WillUsePostgres() {
t.SkipNow()
}

timezones := []string{
"Canada/Newfoundland",
"Africa/Johannesburg",
Expand DownExpand Up@@ -4625,10 +4618,6 @@ func TestGetUserStatusCounts(t *testing.T) {
func TestOrganizationDeleteTrigger(t *testing.T) {
t.Parallel()

if !dbtestutil.WillUsePostgres() {
t.SkipNow()
}

t.Run("WorkspaceExists", func(t *testing.T) {
t.Parallel()
db, _ := dbtestutil.NewDB(t)
Expand DownExpand Up@@ -4942,9 +4931,6 @@ func createPrebuiltWorkspace(

func TestWorkspacePrebuildsView(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.SkipNow()
}

now := dbtime.Now()
orgID := uuid.New()
Expand DownExpand Up@@ -5046,9 +5032,6 @@ func TestWorkspacePrebuildsView(t *testing.T) {

func TestGetPresetsBackoff(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.SkipNow()
}

now := dbtime.Now()
orgID := uuid.New()
Expand DownExpand Up@@ -5565,9 +5548,6 @@ func TestGetPresetsBackoff(t *testing.T) {

func TestGetPresetsAtFailureLimit(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.SkipNow()
}

now := dbtime.Now()
hourBefore := now.Add(-time.Hour)
Expand DownExpand Up@@ -5871,10 +5851,6 @@ func TestGetPresetsAtFailureLimit(t *testing.T) {
func TestWorkspaceAgentNameUniqueTrigger(t *testing.T) {
t.Parallel()

if !dbtestutil.WillUsePostgres() {
t.Skip("This test makes use of a database trigger not implemented in dbmem")
}

createWorkspaceWithAgent := func(t *testing.T, db database.Store, org database.Organization, agentName string) (database.WorkspaceBuild, database.WorkspaceResource, database.WorkspaceAgent) {
t.Helper()

Expand DownExpand Up@@ -6141,10 +6117,6 @@ func requireUsersMatch(t testing.TB, expected []database.User, found []database.
func TestGetRunningPrebuiltWorkspaces(t *testing.T) {
t.Parallel()

if !dbtestutil.WillUsePostgres() {
t.Skip("Test requires PostgreSQL for complex queries")
}

ctx := testutil.Context(t, testutil.WaitLong)
db, _ := dbtestutil.NewDB(t)
now := dbtime.Now()
Expand Down
10 changes: 0 additions & 10 deletionscoderd/notifications/metrics_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,9 +33,6 @@ func TestMetrics(t *testing.T) {
t.Parallel()

// SETUP
if !dbtestutil.WillUsePostgres() {
t.Skip("This test requires postgres; it relies on business-logic only implemented in the database")
}

ctx := dbauthz.AsSystemRestricted(testutil.Context(t, testutil.WaitSuperLong))
store, pubsub := dbtestutil.NewDB(t)
Expand DownExpand Up@@ -390,13 +387,6 @@ func TestInflightDispatchesMetric(t *testing.T) {

func TestCustomMethodMetricCollection(t *testing.T) {
t.Parallel()

// SETUP
if !dbtestutil.WillUsePostgres() {
// UpdateNotificationTemplateMethodByID only makes sense with a real database.
t.Skip("This test requires postgres; it relies on business-logic only implemented in the database")
}

ctx := dbauthz.AsSystemRestricted(testutil.Context(t, testutil.WaitSuperLong))
store, pubsub := dbtestutil.NewDB(t)
logger := testutil.Logger(t)
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp