@@ -2,11 +2,11 @@ import { assert } from 'chai';
22import * as path from 'path' ;
33import { DevContainerConfig , DevContainerFeature } from '../../spec-configuration/configuration' ;
44import { OCIRef } from '../../spec-configuration/containerCollectionsOCI' ;
5- import { Feature , FeatureSet , getBackwardCompatibleFeatureId , getFeatureInstallWrapperScript , processFeatureIdentifier } from '../../spec-configuration/containerFeaturesConfiguration' ;
5+ import { Feature , FeatureSet , getBackwardCompatibleFeatureId , getFeatureInstallWrapperScript , processFeatureIdentifier , updateDeprecatedFeaturesIntoOptions } from '../../spec-configuration/containerFeaturesConfiguration' ;
66import { getSafeId , findContainerUsers } from '../../spec-node/containerFeatures' ;
77import { ImageMetadataEntry } from '../../spec-node/imageMetadata' ;
88import { SubstitutedConfig } from '../../spec-node/utils' ;
9- import { createPlainLog , LogLevel , makeLog } from '../../spec-utils/log' ;
9+ import { createPlainLog , LogLevel , makeLog , nullLog } from '../../spec-utils/log' ;
1010
1111export const output = makeLog ( createPlainLog ( text => process . stdout . write ( text ) , ( ) => LogLevel . Trace ) ) ;
1212
@@ -447,6 +447,58 @@ describe('validate function getBackwardCompatibleFeatureId', () => {
447447 } ) ;
448448} ) ;
449449
450+ describe ( 'validate function updateDeprecatedFeaturesIntoOptions' , ( ) => {
451+ it ( 'should add feature with option' , ( ) => {
452+ const updated = updateDeprecatedFeaturesIntoOptions ( [
453+ {
454+ id : 'jupyterlab' ,
455+ options : { }
456+ }
457+ ] , nullLog ) ;
458+ assert . strictEqual ( updated . length , 1 ) ;
459+ assert . strictEqual ( updated [ 0 ] . id , 'ghcr.io/devcontainers/features/python:1' ) ;
460+ assert . ok ( updated [ 0 ] . options ) ;
461+ assert . strictEqual ( typeof updated [ 0 ] . options , 'object' ) ;
462+ assert . strictEqual ( ( updated [ 0 ] . options as Record < string , string | boolean | undefined > ) [ 'installJupyterlab' ] , true ) ;
463+ } ) ;
464+
465+ it ( 'should update feature with option' , ( ) => {
466+ const updated = updateDeprecatedFeaturesIntoOptions ( [
467+ {
468+ id : 'ghcr.io/devcontainers/features/python:1' ,
469+ options : { }
470+ } ,
471+ {
472+ id : 'jupyterlab' ,
473+ options : { }
474+ }
475+ ] , nullLog ) ;
476+ assert . strictEqual ( updated . length , 1 ) ;
477+ assert . strictEqual ( updated [ 0 ] . id , 'ghcr.io/devcontainers/features/python:1' ) ;
478+ assert . ok ( updated [ 0 ] . options ) ;
479+ assert . strictEqual ( typeof updated [ 0 ] . options , 'object' ) ;
480+ assert . strictEqual ( ( updated [ 0 ] . options as Record < string , string | boolean | undefined > ) [ 'installJupyterlab' ] , true ) ;
481+ } ) ;
482+
483+ it ( 'should update legacy feature with option' , ( ) => {
484+ const updated = updateDeprecatedFeaturesIntoOptions ( [
485+ {
486+ id : 'python' ,
487+ options : { }
488+ } ,
489+ {
490+ id : 'jupyterlab' ,
491+ options : { }
492+ }
493+ ] , nullLog ) ;
494+ assert . strictEqual ( updated . length , 1 ) ;
495+ assert . strictEqual ( updated [ 0 ] . id , 'python' ) ;
496+ assert . ok ( updated [ 0 ] . options ) ;
497+ assert . strictEqual ( typeof updated [ 0 ] . options , 'object' ) ;
498+ assert . strictEqual ( ( updated [ 0 ] . options as Record < string , string | boolean | undefined > ) [ 'installJupyterlab' ] , true ) ;
499+ } ) ;
500+ } ) ;
501+
450502describe ( 'validate function getFeatureInstallWrapperScript' , ( ) => {
451503 it ( 'returns a valid script when optional feature values do not exist' , ( ) => {
452504 const feature : Feature = {
0 commit comments