(t *testing.T)
| 359 | } |
| 360 | |
| 361 | func TestOpenVSCodeDevContainer(t *testing.T) { |
| 362 | t.Parallel() |
| 363 | |
| 364 | if runtime.GOOS != "linux" { |
| 365 | t.Skip("DevContainers are only supported for agents on Linux") |
| 366 | } |
| 367 | |
| 368 | parentAgentName := "agent1" |
| 369 | |
| 370 | devcontainerID := uuid.New() |
| 371 | devcontainerName := "wilson" |
| 372 | workspaceFolder := "/home/coder/wilson" |
| 373 | configFile := path.Join(workspaceFolder, ".devcontainer", "devcontainer.json") |
| 374 | |
| 375 | containerID := uuid.NewString() |
| 376 | containerName := testutil.GetRandomName(t) |
| 377 | containerFolder := "/workspaces/wilson" |
| 378 | |
| 379 | client, workspace, agentToken := setupWorkspaceForAgent(t, func(agents []*proto.Agent) []*proto.Agent { |
| 380 | agents[0].Name = parentAgentName |
| 381 | agents[0].OperatingSystem = runtime.GOOS |
| 382 | return agents |
| 383 | }) |
| 384 | |
| 385 | fCCLI := &fakeContainerCLI{ |
| 386 | resp: codersdk.WorkspaceAgentListContainersResponse{ |
| 387 | Containers: []codersdk.WorkspaceAgentContainer{ |
| 388 | { |
| 389 | ID: containerID, |
| 390 | CreatedAt: dbtime.Now(), |
| 391 | FriendlyName: containerName, |
| 392 | Image: "busybox:latest", |
| 393 | Labels: map[string]string{ |
| 394 | agentcontainers.DevcontainerLocalFolderLabel: workspaceFolder, |
| 395 | agentcontainers.DevcontainerConfigFileLabel: configFile, |
| 396 | agentcontainers.DevcontainerIsTestRunLabel: "true", |
| 397 | "coder.test": t.Name(), |
| 398 | }, |
| 399 | Running: true, |
| 400 | Status: "running", |
| 401 | }, |
| 402 | }, |
| 403 | }, |
| 404 | } |
| 405 | fDCCLI := &fakeDevcontainerCLI{ |
| 406 | config: agentcontainers.DevcontainerConfig{ |
| 407 | Workspace: agentcontainers.DevcontainerWorkspace{ |
| 408 | WorkspaceFolder: containerFolder, |
| 409 | }, |
| 410 | }, |
| 411 | execAgent: func(ctx context.Context, token string) error { |
| 412 | t.Logf("Starting devcontainer subagent with token: %s", token) |
| 413 | _ = agenttest.New(t, client.URL, token) |
| 414 | <-ctx.Done() |
| 415 | return ctx.Err() |
| 416 | }, |
| 417 | } |
| 418 |
nothing calls this directly
no test coverage detected