MCPcopy Create free account
hub / github.com/coder/envbuilder / TestFindDevcontainerJSON

Function TestFindDevcontainerJSON

envbuilder_internal_test.go:13–181  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestFindDevcontainerJSON(t *testing.T) {
14 t.Parallel()
15
16 defaultWorkspaceFolder := "/workspace"
17
18 for _, tt := range []struct {
19 name string
20 workspaceFolder string
21 }{
22 {
23 name: "Default",
24 workspaceFolder: defaultWorkspaceFolder,
25 },
26 {
27 name: "RepoMode",
28 workspaceFolder: "/.envbuilder/repo",
29 },
30 } {
31 t.Run(tt.name, func(t *testing.T) {
32 t.Parallel()
33
34 t.Run("empty filesystem", func(t *testing.T) {
35 t.Parallel()
36
37 // given
38 fs := memfs.New()
39
40 // when
41 _, _, err := findDevcontainerJSON(tt.workspaceFolder, options.Options{
42 Filesystem: fs,
43 WorkspaceFolder: "/workspace",
44 })
45
46 // then
47 require.Error(t, err)
48 })
49
50 t.Run("devcontainer.json is missing", func(t *testing.T) {
51 t.Parallel()
52
53 // given
54 fs := memfs.New()
55 err := fs.MkdirAll(tt.workspaceFolder+"/.devcontainer", 0o600)
56 require.NoError(t, err)
57
58 // when
59 _, _, err = findDevcontainerJSON(tt.workspaceFolder, options.Options{
60 Filesystem: fs,
61 WorkspaceFolder: "/workspace",
62 })
63
64 // then
65 require.Error(t, err)
66 })
67
68 t.Run("default configuration", func(t *testing.T) {
69 t.Parallel()
70

Callers

nothing calls this directly

Calls 3

findDevcontainerJSONFunction · 0.85
ErrorMethod · 0.80
MkdirAllMethod · 0.65

Tested by

no test coverage detected