MCPcopy Index your code
hub / github.com/coder/coder / TestDevcontainerDiscovery

Function TestDevcontainerDiscovery

agent/agentcontainers/api_test.go:4365–4999  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4363}
4364
4365func TestDevcontainerDiscovery(t *testing.T) {
4366 t.Parallel()
4367
4368 if runtime.GOOS == "windows" {
4369 t.Skip("Dev Container tests are not supported on Windows")
4370 }
4371
4372 // We discover dev container projects by searching
4373 // for git repositories at the agent's directory,
4374 // and then recursively walking through these git
4375 // repositories to find any `.devcontainer/devcontainer.json`
4376 // files. These tests are to validate that behavior.
4377
4378 homeDir, err := os.UserHomeDir()
4379 require.NoError(t, err)
4380
4381 tests := []struct {
4382 name string
4383 agentDir string
4384 fs map[string]string
4385 expected []codersdk.WorkspaceAgentDevcontainer
4386 }{
4387 {
4388 name: "GitProjectInRootDir/SingleProject",
4389 agentDir: "/home/coder",
4390 fs: map[string]string{
4391 "/home/coder/.git/HEAD": "",
4392 "/home/coder/.devcontainer/devcontainer.json": "",
4393 },
4394 expected: []codersdk.WorkspaceAgentDevcontainer{
4395 {
4396 WorkspaceFolder: "/home/coder",
4397 ConfigPath: "/home/coder/.devcontainer/devcontainer.json",
4398 Status: codersdk.WorkspaceAgentDevcontainerStatusStopped,
4399 },
4400 },
4401 },
4402 {
4403 name: "GitProjectInRootDir/MultipleProjects",
4404 agentDir: "/home/coder",
4405 fs: map[string]string{
4406 "/home/coder/.git/HEAD": "",
4407 "/home/coder/.devcontainer/devcontainer.json": "",
4408 "/home/coder/site/.devcontainer/devcontainer.json": "",
4409 },
4410 expected: []codersdk.WorkspaceAgentDevcontainer{
4411 {
4412 WorkspaceFolder: "/home/coder",
4413 ConfigPath: "/home/coder/.devcontainer/devcontainer.json",
4414 Status: codersdk.WorkspaceAgentDevcontainerStatusStopped,
4415 },
4416 {
4417 WorkspaceFolder: "/home/coder/site",
4418 ConfigPath: "/home/coder/site/.devcontainer/devcontainer.json",
4419 Status: codersdk.WorkspaceAgentDevcontainerStatusStopped,
4420 },
4421 },
4422 },

Callers

nothing calls this directly

Calls 15

StartMethod · 0.95
CloseMethod · 0.95
RoutesMethod · 0.95
ContextFunction · 0.92
LoggerFunction · 0.92
NewAPIFunction · 0.92
WithClockFunction · 0.92
WithWatcherFunction · 0.92
NewNoopFunction · 0.92
WithFileSystemFunction · 0.92
WithManifestInfoFunction · 0.92
WithContainerCLIFunction · 0.92

Tested by

no test coverage detected