@@ -68,18 +68,12 @@ func TestWorkspaceAgent(t *testing.T) {
68
68
AzureCertificates : certificates ,
69
69
})
70
70
user := coderdtest .CreateFirstUser (t , client )
71
- ws := dbfake .Workspace (t , db , database.Workspace {
71
+ r := dbfake .NewWorkspaceBuilder (t , db ). Seed ( database.Workspace {
72
72
OrganizationID : user .OrganizationID ,
73
73
OwnerID : user .UserID ,
74
- })
75
- dbfake .NewWorkspaceBuildBuilder (t , db , ws ).Resource (& proto.Resource {
76
- Name : "somename" ,
77
- Type : "someinstance" ,
78
- Agents : []* proto.Agent {{
79
- Auth : & proto.Agent_InstanceId {
80
- InstanceId : instanceID ,
81
- },
82
- }},
74
+ }).WithAgent (func (agents []* proto.Agent ) []* proto.Agent {
75
+ agents [0 ].Auth = & proto.Agent_InstanceId {InstanceId : instanceID }
76
+ return agents
83
77
}).Do ()
84
78
85
79
inv , _ := clitest .New (t , "agent" , "--auth" , "azure-instance-identity" , "--agent-url" , client .URL .String ())
@@ -90,8 +84,8 @@ func TestWorkspaceAgent(t *testing.T) {
90
84
91
85
ctx := inv .Context ()
92
86
clitest .Start (t , inv )
93
- coderdtest .AwaitWorkspaceAgents (t , client , ws .ID )
94
- workspace , err := client .Workspace (ctx , ws .ID )
87
+ coderdtest .AwaitWorkspaceAgents (t , client , r . Workspace .ID )
88
+ workspace , err := client .Workspace (ctx , r . Workspace .ID )
95
89
require .NoError (t , err )
96
90
resources := workspace .LatestBuild .Resources
97
91
if assert .NotEmpty (t , workspace .LatestBuild .Resources ) && assert .NotEmpty (t , resources [0 ].Agents ) {
@@ -111,18 +105,12 @@ func TestWorkspaceAgent(t *testing.T) {
111
105
AWSCertificates : certificates ,
112
106
})
113
107
user := coderdtest .CreateFirstUser (t , client )
114
- ws := dbfake .Workspace (t , db , database.Workspace {
108
+ r := dbfake .NewWorkspaceBuilder (t , db ). Seed ( database.Workspace {
115
109
OrganizationID : user .OrganizationID ,
116
110
OwnerID : user .UserID ,
117
- })
118
- dbfake .NewWorkspaceBuildBuilder (t , db , ws ).Resource (& proto.Resource {
119
- Name : "somename" ,
120
- Type : "someinstance" ,
121
- Agents : []* proto.Agent {{
122
- Auth : & proto.Agent_InstanceId {
123
- InstanceId : instanceID ,
124
- },
125
- }},
111
+ }).WithAgent (func (agents []* proto.Agent ) []* proto.Agent {
112
+ agents [0 ].Auth = & proto.Agent_InstanceId {InstanceId : instanceID }
113
+ return agents
126
114
}).Do ()
127
115
128
116
inv , _ := clitest .New (t , "agent" , "--auth" , "aws-instance-identity" , "--agent-url" , client .URL .String ())
@@ -133,8 +121,8 @@ func TestWorkspaceAgent(t *testing.T) {
133
121
134
122
clitest .Start (t , inv )
135
123
ctx := inv .Context ()
136
- coderdtest .AwaitWorkspaceAgents (t , client , ws .ID )
137
- workspace , err := client .Workspace (ctx , ws .ID )
124
+ coderdtest .AwaitWorkspaceAgents (t , client , r . Workspace .ID )
125
+ workspace , err := client .Workspace (ctx , r . Workspace .ID )
138
126
require .NoError (t , err )
139
127
resources := workspace .LatestBuild .Resources
140
128
if assert .NotEmpty (t , resources ) && assert .NotEmpty (t , resources [0 ].Agents ) {
@@ -155,19 +143,14 @@ func TestWorkspaceAgent(t *testing.T) {
155
143
})
156
144
owner := coderdtest .CreateFirstUser (t , client )
157
145
member , memberUser := coderdtest .CreateAnotherUser (t , client , owner .OrganizationID )
158
- ws := dbfake .Workspace (t , db , database.Workspace {
146
+ r := dbfake .NewWorkspaceBuilder (t , db ). Seed ( database.Workspace {
159
147
OrganizationID : owner .OrganizationID ,
160
148
OwnerID : memberUser .ID ,
161
- })
162
- dbfake .NewWorkspaceBuildBuilder (t , db , ws ).Resource (& proto.Resource {
163
- Name : "somename" ,
164
- Type : "someinstance" ,
165
- Agents : []* proto.Agent {{
166
- Auth : & proto.Agent_InstanceId {
167
- InstanceId : instanceID ,
168
- },
169
- }},
149
+ }).WithAgent (func (agents []* proto.Agent ) []* proto.Agent {
150
+ agents [0 ].Auth = & proto.Agent_InstanceId {InstanceId : instanceID }
151
+ return agents
170
152
}).Do ()
153
+
171
154
inv , cfg := clitest .New (t , "agent" , "--auth" , "google-instance-identity" , "--agent-url" , client .URL .String ())
172
155
clitest .SetupConfig (t , member , cfg )
173
156
@@ -179,8 +162,8 @@ func TestWorkspaceAgent(t *testing.T) {
179
162
)
180
163
181
164
ctx := inv .Context ()
182
- coderdtest .AwaitWorkspaceAgents (t , client , ws .ID )
183
- workspace , err := client .Workspace (ctx , ws .ID )
165
+ coderdtest .AwaitWorkspaceAgents (t , client , r . Workspace .ID )
166
+ workspace , err := client .Workspace (ctx , r . Workspace .ID )
184
167
require .NoError (t , err )
185
168
resources := workspace .LatestBuild .Resources
186
169
if assert .NotEmpty (t , resources ) && assert .NotEmpty (t , resources [0 ].Agents ) {
0 commit comments