(t *testing.T)
| 2285 | } |
| 2286 | |
| 2287 | func TestWorkspaceAgent_Metadata(t *testing.T) { |
| 2288 | t.Parallel() |
| 2289 | |
| 2290 | client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{ |
| 2291 | MetadataBatcherOptions: []metadatabatcher.Option{ |
| 2292 | metadatabatcher.WithInterval(100 * time.Millisecond), |
| 2293 | }, |
| 2294 | }) |
| 2295 | user := coderdtest.CreateFirstUser(t, client) |
| 2296 | r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{ |
| 2297 | OrganizationID: user.OrganizationID, |
| 2298 | OwnerID: user.UserID, |
| 2299 | }).WithAgent(func(agents []*proto.Agent) []*proto.Agent { |
| 2300 | agents[0].Metadata = []*proto.Agent_Metadata{ |
| 2301 | { |
| 2302 | DisplayName: "First Meta", |
| 2303 | Key: "foo1", |
| 2304 | Script: "echo hi", |
| 2305 | Interval: 10, |
| 2306 | Timeout: 3, |
| 2307 | }, |
| 2308 | { |
| 2309 | DisplayName: "Second Meta", |
| 2310 | Key: "foo2", |
| 2311 | Script: "echo howdy", |
| 2312 | Interval: 10, |
| 2313 | Timeout: 3, |
| 2314 | }, |
| 2315 | { |
| 2316 | DisplayName: "TooLong", |
| 2317 | Key: "foo3", |
| 2318 | Script: "echo howdy", |
| 2319 | Interval: 10, |
| 2320 | Timeout: 3, |
| 2321 | }, |
| 2322 | } |
| 2323 | return agents |
| 2324 | }).Do() |
| 2325 | |
| 2326 | workspace, err := client.Workspace(context.Background(), r.Workspace.ID) |
| 2327 | require.NoError(t, err) |
| 2328 | for _, res := range workspace.LatestBuild.Resources { |
| 2329 | for _, a := range res.Agents { |
| 2330 | require.Equal(t, codersdk.WorkspaceAgentLifecycleCreated, a.LifecycleState) |
| 2331 | } |
| 2332 | } |
| 2333 | |
| 2334 | agentClient := agentsdk.New(client.URL, agentsdk.WithFixedToken(r.AgentToken)) |
| 2335 | |
| 2336 | ctx := testutil.Context(t, testutil.WaitMedium) |
| 2337 | conn, err := agentClient.ConnectRPC(ctx) |
| 2338 | require.NoError(t, err) |
| 2339 | defer func() { |
| 2340 | cErr := conn.Close() |
| 2341 | require.NoError(t, cErr) |
| 2342 | }() |
| 2343 | aAPI := agentproto.NewDRPCAgentClient(conn) |
| 2344 |
nothing calls this directly
no test coverage detected