mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: remove New----Builder from dbfake function names (#10882)
Drop "New" and "Builder" from the function names, in favor of the top-level resource created. This shortens tests and gives a nice syntax. Since everything is a builder, the prefix and suffix don't add much value and just make things harder to read. I've also chosen to leave `Do()` as the function to insert into the database. Even though it's a builder pattern, I fear `.Build()` might be confusing with Workspace Builds. One other idea is `Insert()` but if we later add dbfake functions that update, this might be inconsistent.
This commit is contained in:
@@ -38,26 +38,26 @@ func setupTestSchedule(t *testing.T, sched *cron.Schedule) (ownerClient, memberC
|
||||
memberClient, memberUser := coderdtest.CreateAnotherUserMutators(t, ownerClient, owner.OrganizationID, nil, func(r *codersdk.CreateUserRequest) {
|
||||
r.Username = "testuser2" // ensure deterministic ordering
|
||||
})
|
||||
_ = dbfake.NewWorkspaceBuilder(t, db).Seed(database.Workspace{
|
||||
_ = dbfake.Workspace(t, db).Seed(database.Workspace{
|
||||
Name: "a-owner",
|
||||
OwnerID: owner.UserID,
|
||||
OrganizationID: owner.OrganizationID,
|
||||
AutostartSchedule: sql.NullString{String: sched.String(), Valid: true},
|
||||
Ttl: sql.NullInt64{Int64: 8 * time.Hour.Nanoseconds(), Valid: true},
|
||||
}).WithAgent().Do()
|
||||
_ = dbfake.NewWorkspaceBuilder(t, db).Seed(database.Workspace{
|
||||
_ = dbfake.Workspace(t, db).Seed(database.Workspace{
|
||||
Name: "b-owner",
|
||||
OwnerID: owner.UserID,
|
||||
OrganizationID: owner.OrganizationID,
|
||||
AutostartSchedule: sql.NullString{String: sched.String(), Valid: true},
|
||||
}).WithAgent().Do()
|
||||
_ = dbfake.NewWorkspaceBuilder(t, db).Seed(database.Workspace{
|
||||
_ = dbfake.Workspace(t, db).Seed(database.Workspace{
|
||||
Name: "c-member",
|
||||
OwnerID: memberUser.ID,
|
||||
OrganizationID: owner.OrganizationID,
|
||||
Ttl: sql.NullInt64{Int64: 8 * time.Hour.Nanoseconds(), Valid: true},
|
||||
}).WithAgent().Do()
|
||||
_ = dbfake.NewWorkspaceBuilder(t, db).Seed(database.Workspace{
|
||||
_ = dbfake.Workspace(t, db).Seed(database.Workspace{
|
||||
Name: "d-member",
|
||||
OwnerID: memberUser.ID,
|
||||
OrganizationID: owner.OrganizationID,
|
||||
|
||||
Reference in New Issue
Block a user