(t *testing.T)
| 5524 | } |
| 5525 | |
| 5526 | func TestWorkspaceAppUpsertRestart(t *testing.T) { |
| 5527 | t.Parallel() |
| 5528 | |
| 5529 | client := coderdtest.New(t, &coderdtest.Options{ |
| 5530 | IncludeProvisionerDaemon: true, |
| 5531 | }) |
| 5532 | user := coderdtest.CreateFirstUser(t, client) |
| 5533 | |
| 5534 | // Define an app to be created with the workspace |
| 5535 | apps := []*proto.App{ |
| 5536 | { |
| 5537 | Id: uuid.NewString(), |
| 5538 | Slug: "test-app", |
| 5539 | DisplayName: "Test App", |
| 5540 | Command: "test-command", |
| 5541 | Url: "http://localhost:8080", |
| 5542 | Icon: "/test.svg", |
| 5543 | }, |
| 5544 | } |
| 5545 | |
| 5546 | // Create template version with workspace app |
| 5547 | version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{ |
| 5548 | Parse: echo.ParseComplete, |
| 5549 | ProvisionGraph: []*proto.Response{{ |
| 5550 | Type: &proto.Response_Graph{ |
| 5551 | Graph: &proto.GraphComplete{ |
| 5552 | Resources: []*proto.Resource{{ |
| 5553 | Name: "test-resource", |
| 5554 | Type: "example", |
| 5555 | Agents: []*proto.Agent{{ |
| 5556 | Id: uuid.NewString(), |
| 5557 | Name: "dev", |
| 5558 | Auth: &proto.Agent_Token{}, |
| 5559 | Apps: apps, |
| 5560 | }}, |
| 5561 | }}, |
| 5562 | }, |
| 5563 | }, |
| 5564 | }}, |
| 5565 | }) |
| 5566 | coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) |
| 5567 | |
| 5568 | // Create template and workspace |
| 5569 | template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) |
| 5570 | workspace := coderdtest.CreateWorkspace(t, client, template.ID) |
| 5571 | coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID) |
| 5572 | |
| 5573 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 5574 | defer cancel() |
| 5575 | |
| 5576 | // Verify initial workspace has the app |
| 5577 | workspace, err := client.Workspace(ctx, workspace.ID) |
| 5578 | require.NoError(t, err) |
| 5579 | require.Len(t, workspace.LatestBuild.Resources[0].Agents, 1) |
| 5580 | agent := workspace.LatestBuild.Resources[0].Agents[0] |
| 5581 | require.Len(t, agent.Apps, 1) |
| 5582 | require.Equal(t, "test-app", agent.Apps[0].Slug) |
| 5583 | require.Equal(t, "Test App", agent.Apps[0].DisplayName) |
nothing calls this directly
no test coverage detected