(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func 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 |
nothing calls this directly
no test coverage detected