@@ -17,7 +17,7 @@ const pkg = require('../../../package.json');
1717describe ( 'tests apply command' , async function ( ) {
1818 this . timeout ( '120s' ) ;
1919
20- const tmp = path . relative ( process . cwd ( ) , path . join ( __dirname , 'tmp4 ' ) ) ;
20+ const tmp = path . relative ( process . cwd ( ) , path . join ( __dirname , 'tmp6 ' ) ) ;
2121 const cli = `npx --prefix ${ tmp } devcontainer` ;
2222
2323 before ( 'Install' , async ( ) => {
@@ -197,3 +197,39 @@ describe('tests generateTemplateDocumentation()', async function () {
197197 assert . isFalse ( invalidDocsExists ) ;
198198 } ) ;
199199} ) ;
200+
201+ describe ( 'template metadata' , async function ( ) {
202+ this . timeout ( '120s' ) ;
203+
204+ const tmp = path . relative ( process . cwd ( ) , path . join ( __dirname , 'tmp7' ) ) ;
205+ const cli = `npx --prefix ${ tmp } devcontainer` ;
206+
207+ // https://github.com/codspace/templates/pkgs/container/templates%2Fmytemplate/255979159?tag=1.0.4
208+ const templateId = 'ghcr.io/codspace/templates/mytemplate@sha256:57cbf968907c74c106b7b2446063d114743ab3f63345f7c108c577915c535185' ;
209+
210+ before ( 'Install' , async ( ) => {
211+ await shellExec ( `rm -rf ${ tmp } /node_modules` ) ;
212+ await shellExec ( `rm -rf ${ tmp } /output` ) ;
213+ await shellExec ( `mkdir -p ${ tmp } ` ) ;
214+ await shellExec ( `npm --prefix ${ tmp } install devcontainers-cli-${ pkg . version } .tgz` ) ;
215+ } ) ;
216+
217+ it ( 'successfully fetches metdata off a published Template' , async function ( ) {
218+ let success = false ;
219+ let result : ExecResult | undefined = undefined ;
220+ try {
221+ result = await shellExec ( `${ cli } templates metadata ${ templateId } --log-level trace` ) ;
222+ success = true ;
223+
224+ } catch ( error ) {
225+ assert . fail ( 'features test sub-command should not throw' ) ;
226+ }
227+
228+ assert . isTrue ( success ) ;
229+ assert . isDefined ( result ) ;
230+ const json = JSON . parse ( result . stdout ) ;
231+ assert . strictEqual ( 'mytemplate' , json . id ) ;
232+ assert . strictEqual ( 'Simple test' , json . description ) ;
233+
234+ } ) ;
235+ } ) ;
0 commit comments