@@ -9,9 +9,34 @@ import { devContainerDown, devContainerUp, shellExec } from '../testUtils';
99
1010const pkg = require ( '../../../package.json' ) ;
1111
12- describe ( 'Registry Compatibility' , function ( ) {
13- this . timeout ( '120s' ) ;
12+ interface TestPlan {
13+ name : string ;
14+ configName : string ;
15+ testFeatureId : string ;
16+ testCommand ?: string ;
17+ testCommandResult ?: RegExp ;
18+ }
19+
20+ const defaultTestPlan = {
21+ testCommand : 'color' ,
22+ testCommandResult : / m y f a v o r i t e c o l o r i s p i n k / ,
23+ } ;
1424
25+ const registryCompatibilityTestPlan : TestPlan [ ] = [
26+ {
27+ name : 'Anonymous access of Azure Container Registry' ,
28+ configName : 'azure-anonymous' ,
29+ testFeatureId : 'devcontainercli.azurecr.io/features/color' ,
30+ } ,
31+ {
32+ name : 'Anonymous access of GHCR' ,
33+ configName : 'github-anonymous' ,
34+ testFeatureId : 'ghcr.io/devcontainers/feature-starter/color' ,
35+ }
36+ ] ;
37+
38+ describe ( 'Registry Compatibility' , function ( ) {
39+ this . timeout ( '1200s' ) ;
1540 const tmp = path . relative ( process . cwd ( ) , path . join ( __dirname , 'tmp' ) ) ;
1641 const cli = `npx --prefix ${ tmp } devcontainer` ;
1742
@@ -21,41 +46,43 @@ describe('Registry Compatibility', function () {
2146 await shellExec ( `npm --prefix ${ tmp } install devcontainers-cli-${ pkg . version } .tgz` ) ;
2247 } ) ;
2348
24- // TODO: Matrix this test against all tested registries
25- describe ( 'Azure Container Registry' , ( ) => {
49+ registryCompatibilityTestPlan . forEach ( ( { name, configName, testFeatureId, testCommand, testCommandResult } ) => {
50+ this . timeout ( '120s' ) ;
51+ describe ( name , ( ) => {
52+ describe ( 'devcontainer up' , ( ) => {
53+ let containerId : string | null = null ;
54+ const testFolder = `${ __dirname } /configs/registry-compatibility/${ configName } ` ;
2655
27- describe ( `'devcontainer up' with a Feature anonymously pulled from ACR` , ( ) => {
28- let containerId : string | null = null ;
29- const testFolder = `${ __dirname } /configs/azure-container-registry` ;
56+ before ( async ( ) => containerId = ( await devContainerUp ( cli , testFolder , { 'logLevel' : 'trace' } ) ) . containerId ) ;
57+ after ( async ( ) => await devContainerDown ( { containerId } ) ) ;
3058
31- before ( async ( ) => containerId = ( await devContainerUp ( cli , testFolder , { 'logLevel' : 'trace' } ) ) . containerId ) ;
32- after ( async ( ) => await devContainerDown ( { containerId } ) ) ;
59+ const cmd = testCommand ?? defaultTestPlan . testCommand ;
60+ const expected = testCommandResult ?? defaultTestPlan . testCommandResult ;
3361
34- it ( 'should exec the color command' , async ( ) => {
35- const res = await shellExec ( `${ cli } exec --workspace-folder ${ testFolder } color` ) ;
36- assert . strictEqual ( res . error , null ) ;
37- assert . match ( res . stdout , / m y f a v o r i t e c o l o r i s p i n k / ) ;
62+ it ( `should exec the ${ cmd } command` , async ( ) => {
63+ const res = await shellExec ( `${ cli } exec --workspace-folder ${ testFolder } ${ cmd } ` ) ;
64+ assert . strictEqual ( res . error , null ) ;
65+ assert . match ( res . stdout , expected ) ;
66+ } ) ;
3867 } ) ;
39- } ) ;
40-
41- describe ( `devcontainer features info manifest` , async ( ) => {
42-
43- it ( 'fetches manifest anonymously from ACR' , async ( ) => {
4468
45- let infoManifestResult : { stdout : string ; stderr : string } | null = null ;
46- let success = false ;
47- try {
48- infoManifestResult = await shellExec ( `${ cli } features info manifest devcontainercli.azurecr.io/features/hello --log-level trace` ) ;
49- success = true ;
50- } catch ( error ) {
51- assert . fail ( 'features info tags sub-command should not throw' ) ;
52- }
69+ describe ( `devcontainer features info manifest` , async ( ) => {
70+ it ( 'fetches manifest' , async ( ) => {
71+ let infoManifestResult : { stdout : string ; stderr : string } | null = null ;
72+ let success = false ;
73+ try {
74+ infoManifestResult = await shellExec ( `${ cli } features info manifest ${ testFeatureId } --log-level trace` ) ;
75+ success = true ;
76+ } catch ( error ) {
77+ assert . fail ( 'features info tags sub-command should not throw' ) ;
78+ }
5379
54- assert . isTrue ( success ) ;
55- assert . isDefined ( infoManifestResult ) ;
56- const manifest = infoManifestResult . stdout ;
57- const regex = / a p p l i c a t i o n \/ v n d \. d e v c o n t a i n e r s \. l a y e r \. v 1 \+ t a r / ;
58- assert . match ( manifest , regex ) ;
80+ assert . isTrue ( success ) ;
81+ assert . isDefined ( infoManifestResult ) ;
82+ const manifest = infoManifestResult . stdout ;
83+ const regex = / a p p l i c a t i o n \/ v n d \. d e v c o n t a i n e r s \. l a y e r \. v 1 \+ t a r / ;
84+ assert . match ( manifest , regex ) ;
85+ } ) ;
5986 } ) ;
6087 } ) ;
6188 } ) ;
0 commit comments