Skip to content

Commit 8b424f0

Browse files
authored
chore: Rename databasefake --> dbfake (#6011)
1 parent f60f06e commit 8b424f0

29 files changed

+152
-152
lines changed

cli/server.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import (
6161
"github.com/coder/coder/coderd"
6262
"github.com/coder/coder/coderd/autobuild/executor"
6363
"github.com/coder/coder/coderd/database"
64-
"github.com/coder/coder/coderd/database/databasefake"
64+
"github.com/coder/coder/coderd/database/dbfake"
6565
"github.com/coder/coder/coderd/database/migrations"
6666
"github.com/coder/coder/coderd/devtunnel"
6767
"github.com/coder/coder/coderd/gitauth"
@@ -461,7 +461,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
461461
AppHostname: appHostname,
462462
AppHostnameRegex: appHostnameRegex,
463463
Logger: logger.Named("coderd"),
464-
Database: databasefake.New(),
464+
Database: dbfake.New(),
465465
DERPMap: derpMap,
466466
Pubsub: database.NewPubsubInMemory(),
467467
CacheDir: cacheDir,
@@ -560,7 +560,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
560560
}
561561

562562
if cfg.InMemoryDatabase.Value {
563-
options.Database = databasefake.New()
563+
options.Database = dbfake.New()
564564
options.Pubsub = database.NewPubsubInMemory()
565565
} else {
566566
logger.Debug(ctx, "connecting to postgresql")

coderd/coderdtest/authorize.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/coder/coder/coderd/database/databasefake"
13+
"github.com/coder/coder/coderd/database/dbfake"
1414

1515
"github.com/go-chi/chi/v5"
1616
"github.com/stretchr/testify/assert"
@@ -30,7 +30,7 @@ func AGPLRoutes(a *AuthTester) (map[string]string, map[string]RouteCheck) {
3030
// in memory fake. This is because the in memory fake does not use SQL, and
3131
// still uses rego. So this boolean indicates how to assert the expected
3232
// behavior.
33-
_, isMemoryDB := a.api.Database.(databasefake.FakeDatabase)
33+
_, isMemoryDB := a.api.Database.(dbfake.FakeDatabase)
3434

3535
// Some quick reused objects
3636
workspaceRBACObj := rbac.ResourceWorkspace.WithID(a.Workspace.ID).InOrg(a.Organization.ID).WithOwner(a.Workspace.OwnerID.String())

coderd/database/databasefake/databasefake.go renamed to coderd/database/dbfake/databasefake.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package databasefake
1+
package dbfake
22

33
import (
44
"context"

coderd/database/databasefake/databasefake_test.go renamed to coderd/database/dbfake/databasefake_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package databasefake_test
1+
package dbfake_test
22

33
import (
44
"context"
@@ -12,14 +12,14 @@ import (
1212

1313
"github.com/coder/coder/coderd/database"
1414

15-
"github.com/coder/coder/coderd/database/databasefake"
15+
"github.com/coder/coder/coderd/database/dbfake"
1616
)
1717

1818
// test that transactions don't deadlock, and that we don't see intermediate state.
1919
func TestInTx(t *testing.T) {
2020
t.Parallel()
2121

22-
uut := databasefake.New()
22+
uut := dbfake.New()
2323

2424
inTx := make(chan any)
2525
queriesDone := make(chan any)
@@ -77,7 +77,7 @@ func TestExactMethods(t *testing.T) {
7777
"IsFakeDB": "Helper function used for unit testing",
7878
}
7979

80-
fake := reflect.TypeOf(databasefake.New())
80+
fake := reflect.TypeOf(dbfake.New())
8181
fakeMethods := methods(fake)
8282

8383
store := reflect.TypeOf((*database.Store)(nil)).Elem()

coderd/database/dbgen/generator_test.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/stretchr/testify/require"
99

1010
"github.com/coder/coder/coderd/database"
11-
"github.com/coder/coder/coderd/database/databasefake"
11+
"github.com/coder/coder/coderd/database/dbfake"
1212
"github.com/coder/coder/coderd/database/dbgen"
1313
)
1414

@@ -17,64 +17,64 @@ func TestGenerator(t *testing.T) {
1717

1818
t.Run("AuditLog", func(t *testing.T) {
1919
t.Parallel()
20-
db := databasefake.New()
20+
db := dbfake.New()
2121
_ = dbgen.AuditLog(t, db, database.AuditLog{})
2222
logs := must(db.GetAuditLogsOffset(context.Background(), database.GetAuditLogsOffsetParams{Limit: 1}))
2323
require.Len(t, logs, 1)
2424
})
2525

2626
t.Run("APIKey", func(t *testing.T) {
2727
t.Parallel()
28-
db := databasefake.New()
28+
db := dbfake.New()
2929
exp, _ := dbgen.APIKey(t, db, database.APIKey{})
3030
require.Equal(t, exp, must(db.GetAPIKeyByID(context.Background(), exp.ID)))
3131
})
3232

3333
t.Run("File", func(t *testing.T) {
3434
t.Parallel()
35-
db := databasefake.New()
35+
db := dbfake.New()
3636
exp := dbgen.File(t, db, database.File{})
3737
require.Equal(t, exp, must(db.GetFileByID(context.Background(), exp.ID)))
3838
})
3939

4040
t.Run("UserLink", func(t *testing.T) {
4141
t.Parallel()
42-
db := databasefake.New()
42+
db := dbfake.New()
4343
exp := dbgen.UserLink(t, db, database.UserLink{})
4444
require.Equal(t, exp, must(db.GetUserLinkByLinkedID(context.Background(), exp.LinkedID)))
4545
})
4646

4747
t.Run("WorkspaceResource", func(t *testing.T) {
4848
t.Parallel()
49-
db := databasefake.New()
49+
db := dbfake.New()
5050
exp := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{})
5151
require.Equal(t, exp, must(db.GetWorkspaceResourceByID(context.Background(), exp.ID)))
5252
})
5353

5454
t.Run("WorkspaceResourceMetadatum", func(t *testing.T) {
5555
t.Parallel()
56-
db := databasefake.New()
56+
db := dbfake.New()
5757
exp := dbgen.WorkspaceResourceMetadatums(t, db, database.WorkspaceResourceMetadatum{})
5858
require.Equal(t, exp, must(db.GetWorkspaceResourceMetadataByResourceIDs(context.Background(), []uuid.UUID{exp[0].WorkspaceResourceID})))
5959
})
6060

6161
t.Run("Job", func(t *testing.T) {
6262
t.Parallel()
63-
db := databasefake.New()
63+
db := dbfake.New()
6464
exp := dbgen.ProvisionerJob(t, db, database.ProvisionerJob{})
6565
require.Equal(t, exp, must(db.GetProvisionerJobByID(context.Background(), exp.ID)))
6666
})
6767

6868
t.Run("Group", func(t *testing.T) {
6969
t.Parallel()
70-
db := databasefake.New()
70+
db := dbfake.New()
7171
exp := dbgen.Group(t, db, database.Group{})
7272
require.Equal(t, exp, must(db.GetGroupByID(context.Background(), exp.ID)))
7373
})
7474

7575
t.Run("GroupMember", func(t *testing.T) {
7676
t.Parallel()
77-
db := databasefake.New()
77+
db := dbfake.New()
7878
g := dbgen.Group(t, db, database.Group{})
7979
u := dbgen.User(t, db, database.User{})
8080
exp := []database.User{u}
@@ -85,14 +85,14 @@ func TestGenerator(t *testing.T) {
8585

8686
t.Run("Organization", func(t *testing.T) {
8787
t.Parallel()
88-
db := databasefake.New()
88+
db := dbfake.New()
8989
exp := dbgen.Organization(t, db, database.Organization{})
9090
require.Equal(t, exp, must(db.GetOrganizationByID(context.Background(), exp.ID)))
9191
})
9292

9393
t.Run("OrganizationMember", func(t *testing.T) {
9494
t.Parallel()
95-
db := databasefake.New()
95+
db := dbfake.New()
9696
exp := dbgen.OrganizationMember(t, db, database.OrganizationMember{})
9797
require.Equal(t, exp, must(db.GetOrganizationMemberByUserID(context.Background(), database.GetOrganizationMemberByUserIDParams{
9898
OrganizationID: exp.OrganizationID,
@@ -102,42 +102,42 @@ func TestGenerator(t *testing.T) {
102102

103103
t.Run("Workspace", func(t *testing.T) {
104104
t.Parallel()
105-
db := databasefake.New()
105+
db := dbfake.New()
106106
exp := dbgen.Workspace(t, db, database.Workspace{})
107107
require.Equal(t, exp, must(db.GetWorkspaceByID(context.Background(), exp.ID)))
108108
})
109109

110110
t.Run("WorkspaceAgent", func(t *testing.T) {
111111
t.Parallel()
112-
db := databasefake.New()
112+
db := dbfake.New()
113113
exp := dbgen.WorkspaceAgent(t, db, database.WorkspaceAgent{})
114114
require.Equal(t, exp, must(db.GetWorkspaceAgentByID(context.Background(), exp.ID)))
115115
})
116116

117117
t.Run("Template", func(t *testing.T) {
118118
t.Parallel()
119-
db := databasefake.New()
119+
db := dbfake.New()
120120
exp := dbgen.Template(t, db, database.Template{})
121121
require.Equal(t, exp, must(db.GetTemplateByID(context.Background(), exp.ID)))
122122
})
123123

124124
t.Run("TemplateVersion", func(t *testing.T) {
125125
t.Parallel()
126-
db := databasefake.New()
126+
db := dbfake.New()
127127
exp := dbgen.TemplateVersion(t, db, database.TemplateVersion{})
128128
require.Equal(t, exp, must(db.GetTemplateVersionByID(context.Background(), exp.ID)))
129129
})
130130

131131
t.Run("ParameterSchema", func(t *testing.T) {
132132
t.Parallel()
133-
db := databasefake.New()
133+
db := dbfake.New()
134134
exp := dbgen.ParameterSchema(t, db, database.ParameterSchema{})
135135
require.Equal(t, []database.ParameterSchema{exp}, must(db.GetParameterSchemasByJobID(context.Background(), exp.JobID)))
136136
})
137137

138138
t.Run("ParameterValue", func(t *testing.T) {
139139
t.Parallel()
140-
db := databasefake.New()
140+
db := dbfake.New()
141141
exp := dbgen.ParameterValue(t, db, database.ParameterValue{})
142142
require.Equal(t, exp, must(db.GetParameterValueByScopeAndName(context.Background(), database.GetParameterValueByScopeAndNameParams{
143143
Scope: exp.Scope,
@@ -148,14 +148,14 @@ func TestGenerator(t *testing.T) {
148148

149149
t.Run("WorkspaceBuild", func(t *testing.T) {
150150
t.Parallel()
151-
db := databasefake.New()
151+
db := dbfake.New()
152152
exp := dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{})
153153
require.Equal(t, exp, must(db.GetWorkspaceBuildByID(context.Background(), exp.ID)))
154154
})
155155

156156
t.Run("User", func(t *testing.T) {
157157
t.Parallel()
158-
db := databasefake.New()
158+
db := dbfake.New()
159159
exp := dbgen.User(t, db, database.User{})
160160
require.Equal(t, exp, must(db.GetUserByID(context.Background(), exp.ID)))
161161
})

coderd/database/dbtestutil/db.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
"github.com/stretchr/testify/require"
1010

1111
"github.com/coder/coder/coderd/database"
12-
"github.com/coder/coder/coderd/database/databasefake"
12+
"github.com/coder/coder/coderd/database/dbfake"
1313
"github.com/coder/coder/coderd/database/postgres"
1414
)
1515

1616
func NewDB(t *testing.T) (database.Store, database.Pubsub) {
1717
t.Helper()
1818

19-
db := databasefake.New()
19+
db := dbfake.New()
2020
pubsub := database.NewPubsubInMemory()
2121
if os.Getenv("DB") != "" {
2222
connectionURL := os.Getenv("CODER_PG_CONNECTION_URL")

0 commit comments

Comments
 (0)