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

Function TestCompileWithFeatures

devcontainer/devcontainer_test.go:48–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestCompileWithFeatures(t *testing.T) {
49 t.Parallel()
50 registry := registrytest.New(t)
51 featureOne := registrytest.WriteContainer(t, registry, emptyRemoteOpts, "coder/one:tomato", features.TarLayerMediaType, map[string]any{
52 "install.sh": "hey",
53 "devcontainer-feature.json": features.Spec{
54 ID: "rust",
55 Version: "tomato",
56 Name: "Rust",
57 Description: "Example description!",
58 ContainerEnv: map[string]string{
59 "TOMATO": "example",
60 },
61 },
62 })
63 featureTwo := registrytest.WriteContainer(t, registry, emptyRemoteOpts, "coder/two:potato", features.TarLayerMediaType, map[string]any{
64 "install.sh": "hey",
65 "devcontainer-feature.json": features.Spec{
66 ID: "go",
67 Version: "potato",
68 Name: "Go",
69 Description: "Example description!",
70 ContainerEnv: map[string]string{
71 "POTATO": "example",
72 },
73 Options: map[string]features.Option{
74 "version": {
75 Type: "string",
76 },
77 },
78 },
79 })
80
81 raw := `{
82 "build": {
83 "dockerfile": "Dockerfile",
84 "context": ".",
85 },
86 // Comments here!
87 "image": "localhost:5000/envbuilder-test-codercom-code-server:latest",
88 "features": {
89 "` + featureOne + `": {},
90 "` + featureTwo + `": "potato"
91 }
92}`
93 dc, err := devcontainer.Parse([]byte(raw))
94 require.NoError(t, err)
95 fs := memfs.New()
96
97 featureOneMD5 := md5.Sum([]byte(featureOne))
98 featureOneDir := fmt.Sprintf("/.envbuilder/features/one-%x", featureOneMD5[:4])
99 featureTwoMD5 := md5.Sum([]byte(featureTwo))
100 featureTwoDir := fmt.Sprintf("/.envbuilder/features/two-%x", featureTwoMD5[:4])
101
102 t.Run("WithoutBuildContexts", func(t *testing.T) {
103 params, err := dc.Compile(fs, "", workingDir, "", "", false, stubLookupEnv)
104 require.NoError(t, err)
105

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
WriteContainerFunction · 0.92
ParseFunction · 0.92
CompileMethod · 0.45

Tested by

no test coverage detected