Skip to content

Commit 4fe07b2

Browse files
authored
update test to add normalizedUserFeatureId
1 parent 508e3c6 commit 4fe07b2

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/test/container-features/featureHelpers.test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { assert } from 'chai';
22
import * as path from 'path';
33
import { DevContainerConfig, DevContainerFeature } from '../../spec-configuration/configuration';
44
import { OCIRef } from '../../spec-configuration/containerCollectionsOCI';
5-
import { Feature, FeatureSet, getBackwardCompatibleFeatureId, getFeatureInstallWrapperScript, processFeatureIdentifier, updateDeprecatedFeaturesIntoOptions } from '../../spec-configuration/containerFeaturesConfiguration';
5+
import { Feature, FeatureSet, getBackwardCompatibleFeatureId, getFeatureInstallWrapperScript, normalizeUserFeatureIdentifier, processFeatureIdentifier, updateDeprecatedFeaturesIntoOptions } from '../../spec-configuration/containerFeaturesConfiguration';
66
import { getSafeId, findContainerUsers } from '../../spec-node/containerFeatures';
77
import { ImageMetadataEntry } from '../../spec-node/imageMetadata';
88
import { SubstitutedConfig } from '../../spec-node/utils';
@@ -62,6 +62,7 @@ describe('validate processFeatureIdentifier', async function () {
6262
// Parsed out of a user's devcontainer.json
6363
let userFeature: DevContainerFeature = {
6464
rawUserFeatureId: 'docker-in-docker',
65+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'docker-in-docker'),
6566
options: {}
6667
};
6768
const featureSet = await processFeatureIdentifier(params, defaultConfigPath, workspaceRoot, userFeature);
@@ -83,6 +84,7 @@ describe('validate processFeatureIdentifier', async function () {
8384
it('should process github-repo (without version)', async function () {
8485
const userFeature: DevContainerFeature = {
8586
rawUserFeatureId: 'octocat/myfeatures/helloworld',
87+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'octocat/myfeatures/helloworld'),
8688
options: {},
8789
};
8890
const featureSet = await processFeatureIdentifier(params, defaultConfigPath, workspaceRoot, userFeature);
@@ -111,6 +113,7 @@ describe('validate processFeatureIdentifier', async function () {
111113
it('should process github-repo (with version)', async function () {
112114
const userFeature: DevContainerFeature = {
113115
rawUserFeatureId: 'octocat/myfeatures/[email protected]',
116+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'octocat/myfeatures/[email protected]'),
114117
options: {},
115118
};
116119
const featureSet = await processFeatureIdentifier(params, defaultConfigPath, workspaceRoot, userFeature);
@@ -140,6 +143,7 @@ describe('validate processFeatureIdentifier', async function () {
140143
it('should process direct-tarball (v2 with direct tar download)', async function () {
141144
const userFeature: DevContainerFeature = {
142145
rawUserFeatureId: 'https://example.com/some/long/path/devcontainer-feature-ruby.tgz',
146+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'https://example.com/some/long/path/devcontainer-feature-ruby.tgz'),
143147
options: {},
144148
};
145149

@@ -158,6 +162,7 @@ describe('validate processFeatureIdentifier', async function () {
158162
it('local-path should parse when provided a relative path with Config file in $WORKSPACE_ROOT/.devcontainer', async function () {
159163
const userFeature: DevContainerFeature = {
160164
rawUserFeatureId: './featureA',
165+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, './featureA'),
161166
options: {},
162167
};
163168

@@ -173,6 +178,7 @@ describe('validate processFeatureIdentifier', async function () {
173178
it('local-path should parse when provided relative path with config file in $WORKSPACE_ROOT', async function () {
174179
const userFeature: DevContainerFeature = {
175180
rawUserFeatureId: './.devcontainer/featureB',
181+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, './.devcontainer/featureB'),
176182
options: {},
177183
};
178184

@@ -188,6 +194,7 @@ describe('validate processFeatureIdentifier', async function () {
188194
it('should process oci registry (without tag)', async function () {
189195
const userFeature: DevContainerFeature = {
190196
rawUserFeatureId: 'ghcr.io/codspace/features/ruby',
197+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'ghcr.io/codspace/features/ruby'),
191198
options: {},
192199
};
193200

@@ -224,6 +231,7 @@ describe('validate processFeatureIdentifier', async function () {
224231
it('should process oci registry (with a digest)', async function () {
225232
const userFeature: DevContainerFeature = {
226233
rawUserFeatureId: 'ghcr.io/devcontainers/features/ruby@sha256:4ef08c9c3b708f3c2faecc5a898b39736423dd639f09f2a9f8bf9b0b9252ef0a',
234+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'ghcr.io/devcontainers/features/ruby@sha256:4ef08c9c3b708f3c2faecc5a898b39736423dd639f09f2a9f8bf9b0b9252ef0a'),
227235
options: {},
228236
};
229237

@@ -260,6 +268,7 @@ describe('validate processFeatureIdentifier', async function () {
260268
it('should process oci registry (with a tag)', async function () {
261269
const userFeature: DevContainerFeature = {
262270
rawUserFeatureId: 'ghcr.io/codspace/features/ruby:1.0.13',
271+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'ghcr.io/codspace/features/ruby:1.0.13'),
263272
options: {},
264273
};
265274

@@ -298,6 +307,7 @@ describe('validate processFeatureIdentifier', async function () {
298307
it('local-path should fail to parse when provided absolute path and defaultConfigPath with a .devcontainer', async function () {
299308
const userFeature: DevContainerFeature = {
300309
rawUserFeatureId: '/some/long/path/to/helloworld',
310+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, '/some/long/path/to/helloworld'),
301311
options: {},
302312
};
303313

@@ -310,6 +320,7 @@ describe('validate processFeatureIdentifier', async function () {
310320
it('local-path should fail to parse when provided an absolute path and defaultConfigPath without a .devcontainer', async function () {
311321
const userFeature: DevContainerFeature = {
312322
rawUserFeatureId: '/some/long/path/to/helloworld',
323+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, '/some/long/path/to/helloworld'),
313324
options: {},
314325
};
315326

@@ -322,6 +333,7 @@ describe('validate processFeatureIdentifier', async function () {
322333
it('local-path should fail to parse when provided an a relative path breaking out of the .devcontainer folder', async function () {
323334
const userFeature: DevContainerFeature = {
324335
rawUserFeatureId: '../featureC',
336+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, '../featureC'),
325337
options: {},
326338
};
327339

@@ -334,6 +346,7 @@ describe('validate processFeatureIdentifier', async function () {
334346
it('should fail parsing a generic tar with no feature and trailing slash', async function () {
335347
const userFeature: DevContainerFeature = {
336348
rawUserFeatureId: 'https://example.com/some/long/path/devcontainer-features.tgz/',
349+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'https://example.com/some/long/path/devcontainer-features.tgz/'),
337350
options: {},
338351
};
339352

@@ -344,6 +357,7 @@ describe('validate processFeatureIdentifier', async function () {
344357
it('should not parse gitHub without triple slash', async function () {
345358
const userFeature: DevContainerFeature = {
346359
rawUserFeatureId: 'octocat/myfeatures#helloworld',
360+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'octocat/myfeatures#helloworld'),
347361
options: {},
348362
};
349363

@@ -354,6 +368,7 @@ describe('validate processFeatureIdentifier', async function () {
354368
it('should fail parsing a generic tar with no feature and no trailing slash', async function () {
355369
const userFeature: DevContainerFeature = {
356370
rawUserFeatureId: 'https://example.com/some/long/path/devcontainer-features.tgz',
371+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'https://example.com/some/long/path/devcontainer-features.tgz'),
357372
options: {},
358373
};
359374

@@ -364,6 +379,7 @@ describe('validate processFeatureIdentifier', async function () {
364379
it('should fail parsing a generic tar with a hash but no feature', async function () {
365380
const userFeature: DevContainerFeature = {
366381
rawUserFeatureId: 'https://example.com/some/long/path/devcontainer-features.tgz#',
382+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'https://example.com/some/long/path/devcontainer-features.tgz#'),
367383
options: {},
368384
};
369385

@@ -374,6 +390,7 @@ describe('validate processFeatureIdentifier', async function () {
374390
it('should fail parsing a marketplace shorthand with only two segments and a hash with no feature', async function () {
375391
const userFeature: DevContainerFeature = {
376392
rawUserFeatureId: 'octocat/myfeatures#',
393+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'octocat/myfeatures#'),
377394
options: {},
378395
};
379396

@@ -384,6 +401,7 @@ describe('validate processFeatureIdentifier', async function () {
384401
it('should fail parsing a marketplace shorthand with only two segments (no feature)', async function () {
385402
const userFeature: DevContainerFeature = {
386403
rawUserFeatureId: 'octocat/myfeatures',
404+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'octocat/myfeatures'),
387405
options: {},
388406
};
389407

@@ -394,6 +412,7 @@ describe('validate processFeatureIdentifier', async function () {
394412
it('should fail parsing a marketplace shorthand with an invalid feature name (1)', async function () {
395413
const userFeature: DevContainerFeature = {
396414
rawUserFeatureId: 'octocat/myfeatures/@mycoolfeature',
415+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'octocat/myfeatures/@mycoolfeature'),
397416
options: {},
398417
};
399418

@@ -404,6 +423,7 @@ describe('validate processFeatureIdentifier', async function () {
404423
it('should fail parsing a marketplace shorthand with an invalid feature name (2)', async function () {
405424
const userFeature: DevContainerFeature = {
406425
rawUserFeatureId: 'octocat/myfeatures/MY_$UPER_COOL_FEATURE',
426+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'octocat/myfeatures/MY_$UPER_COOL_FEATURE'),
407427
options: {},
408428
};
409429

@@ -414,6 +434,7 @@ describe('validate processFeatureIdentifier', async function () {
414434
it('should fail parsing a marketplace shorthand with only two segments, no hash, and with a version', async function () {
415435
const userFeature: DevContainerFeature = {
416436
rawUserFeatureId: 'octocat/[email protected]',
437+
normalizedUserFeatureId: normalizeUserFeatureIdentifier(output, 'octocat/[email protected]'),
417438
options: {},
418439
};
419440

0 commit comments

Comments
 (0)