mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: remove dbfake.WorkspaceBuild in favor of builder pattern (#10814)
I'd like to convert dbfake into a builder pattern to prevent a proliferation of XXXWithYYY methods. This is one step of the way by removing the Non-builder function.
This commit is contained in:
+6
-6
@@ -69,7 +69,7 @@ func TestWorkspaceAgent(t *testing.T) {
|
||||
OrganizationID: user.OrganizationID,
|
||||
OwnerID: user.UserID,
|
||||
})
|
||||
dbfake.WorkspaceBuild(t, db, ws, database.WorkspaceBuild{}, &proto.Resource{
|
||||
dbfake.NewWorkspaceBuildBuilder(t, db, ws).Resource(&proto.Resource{
|
||||
Name: "somename",
|
||||
Type: "someinstance",
|
||||
Agents: []*proto.Agent{{
|
||||
@@ -77,7 +77,7 @@ func TestWorkspaceAgent(t *testing.T) {
|
||||
InstanceId: instanceID,
|
||||
},
|
||||
}},
|
||||
})
|
||||
}).Do()
|
||||
|
||||
inv, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String())
|
||||
inv = inv.WithContext(
|
||||
@@ -112,7 +112,7 @@ func TestWorkspaceAgent(t *testing.T) {
|
||||
OrganizationID: user.OrganizationID,
|
||||
OwnerID: user.UserID,
|
||||
})
|
||||
dbfake.WorkspaceBuild(t, db, ws, database.WorkspaceBuild{}, &proto.Resource{
|
||||
dbfake.NewWorkspaceBuildBuilder(t, db, ws).Resource(&proto.Resource{
|
||||
Name: "somename",
|
||||
Type: "someinstance",
|
||||
Agents: []*proto.Agent{{
|
||||
@@ -120,7 +120,7 @@ func TestWorkspaceAgent(t *testing.T) {
|
||||
InstanceId: instanceID,
|
||||
},
|
||||
}},
|
||||
})
|
||||
}).Do()
|
||||
|
||||
inv, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String())
|
||||
inv = inv.WithContext(
|
||||
@@ -156,7 +156,7 @@ func TestWorkspaceAgent(t *testing.T) {
|
||||
OrganizationID: owner.OrganizationID,
|
||||
OwnerID: memberUser.ID,
|
||||
})
|
||||
dbfake.WorkspaceBuild(t, db, ws, database.WorkspaceBuild{}, &proto.Resource{
|
||||
dbfake.NewWorkspaceBuildBuilder(t, db, ws).Resource(&proto.Resource{
|
||||
Name: "somename",
|
||||
Type: "someinstance",
|
||||
Agents: []*proto.Agent{{
|
||||
@@ -164,7 +164,7 @@ func TestWorkspaceAgent(t *testing.T) {
|
||||
InstanceId: instanceID,
|
||||
},
|
||||
}},
|
||||
})
|
||||
}).Do()
|
||||
inv, cfg := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
|
||||
clitest.SetupConfig(t, member, cfg)
|
||||
|
||||
|
||||
@@ -696,7 +696,7 @@ func TestConfigSSH_Hostnames(t *testing.T) {
|
||||
OrganizationID: owner.OrganizationID,
|
||||
OwnerID: memberUser.ID,
|
||||
})
|
||||
dbfake.WorkspaceBuild(t, db, ws, database.WorkspaceBuild{}, resources...)
|
||||
dbfake.NewWorkspaceBuildBuilder(t, db, ws).Resource(resources...).Do()
|
||||
sshConfigFile := sshConfigFileName(t)
|
||||
|
||||
inv, root := clitest.New(t, "config-ssh", "--ssh-config-file", sshConfigFile)
|
||||
|
||||
+2
-2
@@ -151,7 +151,7 @@ func TestSSH(t *testing.T) {
|
||||
pty.WriteLine("echo hell'o'")
|
||||
pty.ExpectMatchContext(ctx, "hello")
|
||||
|
||||
_ = dbfake.WorkspaceBuildBuilder(t, store, workspace).
|
||||
_ = dbfake.NewWorkspaceBuildBuilder(t, store, workspace).
|
||||
Seed(database.WorkspaceBuild{
|
||||
Transition: database.WorkspaceTransitionStop,
|
||||
BuildNumber: 2,
|
||||
@@ -520,7 +520,7 @@ func TestSSH(t *testing.T) {
|
||||
err = session.Shell()
|
||||
require.NoError(t, err)
|
||||
|
||||
_ = dbfake.WorkspaceBuildBuilder(t, store, workspace).
|
||||
_ = dbfake.NewWorkspaceBuildBuilder(t, store, workspace).
|
||||
Seed(database.WorkspaceBuild{
|
||||
Transition: database.WorkspaceTransitionStop,
|
||||
BuildNumber: 2,
|
||||
|
||||
Reference in New Issue
Block a user