@@ -22,17 +22,11 @@ import * as rimraf from 'rimraf';
2222import { Context } from '../../src/context' ;
2323import { Build } from '../../src/buildx/build' ;
2424
25- import { BuildMetadata } from '../../src/types/buildx/build' ;
26-
2725const fixturesDir = path . join ( __dirname , '..' , 'fixtures' ) ;
2826// prettier-ignore
2927const tmpDir = path . join ( process . env . TEMP || '/tmp' , 'buildx-inputs-jest' ) ;
3028const tmpName = path . join ( tmpDir , '.tmpname-jest' ) ;
31- const metadata : BuildMetadata = {
32- 'buildx.build.ref' : 'default/default/n6ibcp9b2pw108rrz7ywdznvo' ,
33- 'containerimage.config.digest' : 'sha256:059b68a595b22564a1cbc167f369349fdc2ecc1f7bc092c2235cbf601a795fd' ,
34- 'containerimage.digest' : 'sha256:b09b9482c72371486bb2c1d2c2a2633ed1d0b8389e12c8d52b9e052725c0c83c'
35- } ;
29+ const metadata = JSON . parse ( fs . readFileSync ( path . join ( fixturesDir , 'metadata.json' ) , 'utf-8' ) ) ;
3630
3731jest . spyOn ( Context , 'tmpDir' ) . mockImplementation ( ( ) : string => {
3832 if ( ! fs . existsSync ( tmpDir ) ) {
@@ -78,6 +72,18 @@ describe('resolveRef', () => {
7872 } ) ;
7973} ) ;
8074
75+ describe ( 'resolveProvenance' , ( ) => {
76+ it ( 'matches' , async ( ) => {
77+ const build = new Build ( ) ;
78+ fs . writeFileSync ( build . getMetadataFilePath ( ) , JSON . stringify ( metadata ) ) ;
79+ const provenance = build . resolveProvenance ( ) ;
80+ expect ( provenance ) . toBeDefined ( ) ;
81+ expect ( provenance ?. buildType ) . toEqual ( 'https://mobyproject.org/buildkit@v1' ) ;
82+ expect ( provenance ?. materials ) . toBeDefined ( ) ;
83+ expect ( provenance ?. materials ?. length ) . toEqual ( 2 ) ;
84+ } ) ;
85+ } ) ;
86+
8187describe ( 'resolveDigest' , ( ) => {
8288 it ( 'matches' , async ( ) => {
8389 const build = new Build ( ) ;
0 commit comments