Skip to content

Commit b6c2671

Browse files
committed
more test fixes
1 parent cf5acd3 commit b6c2671

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

enterprise/coderd/provisionerdaemons_test.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -256,21 +256,16 @@ func TestProvisionerDaemonServe(t *testing.T) {
256256
authToken := uuid.NewString()
257257
data, err := echo.Tar(&echo.Responses{
258258
Parse: echo.ParseComplete,
259-
ProvisionGraph: []*sdkproto.Response{{
260-
Type: &sdkproto.Response_Graph{
261-
Graph: &sdkproto.GraphComplete{
262-
Resources: []*sdkproto.Resource{{
263-
Name: "example",
264-
Type: "aws_instance",
265-
Agents: []*sdkproto.Agent{{
266-
Id: uuid.NewString(),
267-
Name: "example",
268-
}},
269-
}},
270-
},
271-
},
272-
}},
273-
ProvisionGraph: echo.ProvisionGraphWithAgent(authToken),
259+
ProvisionGraph: echo.ProvisionGraphWithAgent(authToken, func(g *sdkproto.GraphComplete) {
260+
g.Resources = []*sdkproto.Resource{{
261+
Name: "example",
262+
Type: "aws_instance",
263+
Agents: []*sdkproto.Agent{{
264+
Id: uuid.NewString(),
265+
Name: "example",
266+
}},
267+
}}
268+
}),
274269
})
275270
require.NoError(t, err)
276271
//nolint:gocritic // Not testing file upload in this test.

provisioner/echo/serve.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,27 @@ func ProvisionApplyWithAgentAndAPIKeyScope(authToken string, apiKeyScope string)
4747

4848
// ProvisionGraphWithAgent returns provision responses that will mock a fake
4949
// "aws_instance" resource with an agent that has the given auth token.
50-
func ProvisionGraphWithAgent(authToken string) []*proto.Response {
50+
func ProvisionGraphWithAgent(authToken string, muts ...func(g *proto.GraphComplete)) []*proto.Response {
51+
gc := &proto.GraphComplete{
52+
Resources: []*proto.Resource{{
53+
Name: "example",
54+
Type: "aws_instance",
55+
Agents: []*proto.Agent{{
56+
Id: uuid.NewString(),
57+
Name: "example",
58+
Auth: &proto.Agent_Token{
59+
Token: authToken,
60+
},
61+
}},
62+
}},
63+
}
64+
for _, mut := range muts {
65+
mut(gc)
66+
}
67+
5168
return []*proto.Response{{
5269
Type: &proto.Response_Graph{
53-
Graph: &proto.GraphComplete{
54-
Resources: []*proto.Resource{{
55-
Name: "example",
56-
Type: "aws_instance",
57-
Agents: []*proto.Agent{{
58-
Id: uuid.NewString(),
59-
Name: "example",
60-
Auth: &proto.Agent_Token{
61-
Token: authToken,
62-
},
63-
}},
64-
}},
65-
},
70+
Graph: gc,
6671
},
6772
}}
6873
}

0 commit comments

Comments
 (0)