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

Commit2999996

Browse files
Remove references to dbtestutil.WillUsePostgres
Since we removed the in-memory database and now only use Postgres,the WillUsePostgres() function always returned true. This commit:- Removes all test skip conditions that checked WillUsePostgres- Removes the WillUsePostgres function from dbtestutil- Simplifies ErrorsWithPG to always call Errors- Marks ErrorsWithInMemDB as deprecated (kept for compatibility)Fixescoder/internal#758Co-authored-by: hugodutka <28019628+hugodutka@users.noreply.github.com>
1 parent5d66f1f commit2999996

32 files changed

+35
-342
lines changed

‎cli/delete_test.go‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ func TestDelete(t *testing.T) {
185185

186186
t.Run("WarnNoProvisioners",func(t*testing.T) {
187187
t.Parallel()
188-
if!dbtestutil.WillUsePostgres() {
189-
t.Skip("this test requires postgres")
190-
}
191188

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

229226
t.Run("Prebuilt workspace delete permissions",func(t*testing.T) {
230227
t.Parallel()
231-
if!dbtestutil.WillUsePostgres() {
232-
t.Skip("this test requires postgres")
233-
}
234228

235229
// Setup
236230
db,pb:=dbtestutil.NewDB(t,dbtestutil.WithDumpOnFailure())

‎cli/server_regenerate_vapid_keypair_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ import (
1717

1818
funcTestRegenerateVapidKeypair(t*testing.T) {
1919
t.Parallel()
20-
if!dbtestutil.WillUsePostgres() {
21-
t.Skip("this test is only supported on postgres")
22-
}
2320

2421
t.Run("NoExistingVAPIDKeys",func(t*testing.T) {
2522
t.Parallel()

‎cli/server_test.go‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,6 @@ func TestServer(t *testing.T) {
348348

349349
runGitHubProviderTest:=func(t*testing.T,tctestCase) {
350350
t.Parallel()
351-
if!dbtestutil.WillUsePostgres() {
352-
t.Skip("test requires postgres")
353-
}
354351

355352
ctx,cancelFunc:=context.WithCancel(testutil.Context(t,testutil.WaitLong))
356353
defercancelFunc()
@@ -2142,10 +2139,6 @@ func TestServerYAMLConfig(t *testing.T) {
21422139
funcTestConnectToPostgres(t*testing.T) {
21432140
t.Parallel()
21442141

2145-
if!dbtestutil.WillUsePostgres() {
2146-
t.Skip("this test does not make sense without postgres")
2147-
}
2148-
21492142
t.Run("Migrate",func(t*testing.T) {
21502143
t.Parallel()
21512144

@@ -2256,10 +2249,6 @@ type runServerOpts struct {
22562249
funcTestServer_TelemetryDisabled_FinalReport(t*testing.T) {
22572250
t.Parallel()
22582251

2259-
if!dbtestutil.WillUsePostgres() {
2260-
t.Skip("this test requires postgres")
2261-
}
2262-
22632252
telemetryServerURL,deployment,snapshot:=mockTelemetryServer(t)
22642253
dbConnURL,err:=dbtestutil.Open(t)
22652254
require.NoError(t,err)

‎coderd/aitasks_test.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ func TestAITasksPrompts(t *testing.T) {
5454
t.Run("MultipleBuilds",func(t*testing.T) {
5555
t.Parallel()
5656

57-
if!dbtestutil.WillUsePostgres() {
58-
t.Skip("This test checks RBAC, which is not supported in the in-memory database")
59-
}
60-
6157
adminClient:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerDaemon:true})
6258
first:=coderdtest.CreateFirstUser(t,adminClient)
6359
memberClient,_:=coderdtest.CreateAnotherUser(t,adminClient,first.OrganizationID)

‎coderd/autobuild/lifecycle_executor_test.go‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,6 @@ func TestExecutorWorkspaceAutostopNoWaitChangedMyMind(t *testing.T) {
776776
}
777777

778778
funcTestExecutorAutostartMultipleOK(t*testing.T) {
779-
if!dbtestutil.WillUsePostgres() {
780-
t.Skip(`This test only really works when using a "real" database, similar to a HA setup`)
781-
}
782779

783780
t.Parallel()
784781

@@ -1259,10 +1256,6 @@ func TestNotifications(t *testing.T) {
12591256
funcTestExecutorPrebuilds(t*testing.T) {
12601257
t.Parallel()
12611258

1262-
if!dbtestutil.WillUsePostgres() {
1263-
t.Skip("this test requires postgres")
1264-
}
1265-
12661259
// Prebuild workspaces should not be autostopped when the deadline is reached.
12671260
// After being claimed, the workspace should stop at the deadline.
12681261
t.Run("OnlyStopsAfterClaimed",func(t*testing.T) {

‎coderd/database/db_test.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ func TestNestedInTx(t *testing.T) {
8585
functestSQLDB(t testing.TB)*sql.DB {
8686
t.Helper()
8787

88-
if!dbtestutil.WillUsePostgres() {
89-
t.Skip("this test requires postgres")
90-
}
91-
9288
connection,err:=dbtestutil.Open(t)
9389
require.NoError(t,err)
9490

‎coderd/database/dbauthz/setup_test.go‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,20 +431,14 @@ func (m *expects) Errors(err error) *expects {
431431
}
432432

433433
// ErrorsWithPG is optional. If it is never called, it will not be asserted.
434-
//It will only be asserted if the testisrunning with a Postgres database.
434+
//Since we removed the in-memory database, thisisnow equivalent to Errors.
435435
func (m*expects)ErrorsWithPG(errerror)*expects {
436-
ifdbtestutil.WillUsePostgres() {
437-
returnm.Errors(err)
438-
}
439-
returnm
436+
returnm.Errors(err)
440437
}
441438

442-
// ErrorsWithInMemDB isoptional. If it is never called, it will not be asserted.
443-
//It will only be asserted if the test is running with an in-memory database.
439+
// ErrorsWithInMemDB isdeprecated. The in-memory database has been removed.
440+
//This method is kept for backwards compatibility but does nothing.
444441
func (m*expects)ErrorsWithInMemDB(errerror)*expects {
445-
if!dbtestutil.WillUsePostgres() {
446-
returnm.Errors(err)
447-
}
448442
returnm
449443
}
450444

‎coderd/database/dbrollup/dbrollup_test.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ func (w *wrapUpsertDB) UpsertTemplateUsageStats(ctx context.Context) error {
5252
funcTestRollup_TwoInstancesUseLocking(t*testing.T) {
5353
t.Parallel()
5454

55-
if!dbtestutil.WillUsePostgres() {
56-
t.Skip("Skipping test; only works with PostgreSQL.")
57-
}
58-
5955
db,ps:=dbtestutil.NewDB(t,dbtestutil.WithDumpOnFailure())
6056
logger:=testutil.Logger(t)
6157

‎coderd/database/dbtestutil/db.go‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ import (
2323
"github.com/coder/coder/v2/testutil"
2424
)
2525

26-
// WillUsePostgres returns true if a call to NewDB() will return a real, postgres-backed Store and Pubsub.
27-
// TODO(hugodutka): since we removed the in-memory database, this is always true,
28-
// and we need to remove this function. https://github.com/coder/internal/issues/758
29-
funcWillUsePostgres()bool {
30-
returntrue
31-
}
32-
3326
typeoptionsstruct {
3427
fixedTimezonestring
3528
dumpOnFailurebool
@@ -75,10 +68,6 @@ func withReturnSQLDB(f func(*sql.DB)) Option {
7568
funcNewDBWithSQLDB(t testing.TB,opts...Option) (database.Store, pubsub.Pubsub,*sql.DB) {
7669
t.Helper()
7770

78-
if!WillUsePostgres() {
79-
t.Fatal("cannot use NewDBWithSQLDB without PostgreSQL, consider adding `if !dbtestutil.WillUsePostgres() { t.Skip() }` to this test")
80-
}
81-
8271
varsqlDB*sql.DB
8372
opts=append(opts,withReturnSQLDB(func(db*sql.DB) {
8473
sqlDB=db

‎coderd/database/dbtestutil/postgres_test.go‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ func TestMain(m *testing.M) {
2020

2121
funcTestOpen(t*testing.T) {
2222
t.Parallel()
23-
if!dbtestutil.WillUsePostgres() {
24-
t.Skip("this test requires postgres")
25-
}
2623

2724
connect,err:=dbtestutil.Open(t)
2825
require.NoError(t,err)
@@ -37,9 +34,6 @@ func TestOpen(t *testing.T) {
3734

3835
funcTestOpen_InvalidDBFrom(t*testing.T) {
3936
t.Parallel()
40-
if!dbtestutil.WillUsePostgres() {
41-
t.Skip("this test requires postgres")
42-
}
4337

4438
_,err:=dbtestutil.Open(t,dbtestutil.WithDBFrom("__invalid__"))
4539
require.Error(t,err)
@@ -49,9 +43,6 @@ func TestOpen_InvalidDBFrom(t *testing.T) {
4943

5044
funcTestOpen_ValidDBFrom(t*testing.T) {
5145
t.Parallel()
52-
if!dbtestutil.WillUsePostgres() {
53-
t.Skip("this test requires postgres")
54-
}
5546

5647
// first check if we can create a new template db
5748
dsn,err:=dbtestutil.Open(t,dbtestutil.WithDBFrom(""))
@@ -115,9 +106,6 @@ func TestOpen_ValidDBFrom(t *testing.T) {
115106
funcTestOpen_Panic(t*testing.T) {
116107
t.Skip("unskip this to manually test that we don't leak a database into postgres")
117108
t.Parallel()
118-
if!dbtestutil.WillUsePostgres() {
119-
t.Skip("this test requires postgres")
120-
}
121109

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

134119
_,err:=dbtestutil.Open(t)
135120
require.NoError(t,err)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp