chore: remove dbfake.WorkspaceWithAgent (#10879)

Replace dbfake.WorkspaceWithAgent() with the builder pattern and remove this function.
This commit is contained in:
Spike Curtis
2023-11-27 14:30:15 +04:00
committed by GitHub
parent 82d5130b07
commit 78283a7fb9
9 changed files with 127 additions and 125 deletions
+12 -9
View File
@@ -77,12 +77,15 @@ func TestConfigSSH(t *testing.T) {
})
owner := coderdtest.CreateFirstUser(t, client)
member, memberUser := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
ws, authToken := dbfake.WorkspaceWithAgent(t, db, database.Workspace{
OrganizationID: owner.OrganizationID,
OwnerID: memberUser.ID,
})
_ = agenttest.New(t, client.URL, authToken)
resources := coderdtest.AwaitWorkspaceAgents(t, client, ws.ID)
r := dbfake.NewWorkspaceBuilder(t, db).
Seed(database.Workspace{
OrganizationID: owner.OrganizationID,
OwnerID: memberUser.ID,
}).
WithAgent().
Do()
_ = agenttest.New(t, client.URL, r.AgentToken)
resources := coderdtest.AwaitWorkspaceAgents(t, client, r.Workspace.ID)
agentConn, err := client.DialWorkspaceAgent(context.Background(), resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer agentConn.Close()
@@ -153,7 +156,7 @@ func TestConfigSSH(t *testing.T) {
home := filepath.Dir(filepath.Dir(sshConfigFile))
// #nosec
sshCmd := exec.Command("ssh", "-F", sshConfigFile, hostname+ws.Name, "echo", "test")
sshCmd := exec.Command("ssh", "-F", sshConfigFile, hostname+r.Workspace.Name, "echo", "test")
pty = ptytest.New(t)
// Set HOME because coder config is included from ~/.ssh/coder.
sshCmd.Env = append(sshCmd.Env, fmt.Sprintf("HOME=%s", home))
@@ -572,10 +575,10 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
client, db := coderdtest.NewWithDatabase(t, nil)
user := coderdtest.CreateFirstUser(t, client)
if tt.hasAgent {
_, _ = dbfake.WorkspaceWithAgent(t, db, database.Workspace{
_ = dbfake.NewWorkspaceBuilder(t, db).Seed(database.Workspace{
OrganizationID: user.OrganizationID,
OwnerID: user.UserID,
})
}).WithAgent().Do()
}
// Prepare ssh config files.