@@ -70,7 +70,8 @@ describe('create', () => {
7070
7171 const result = await new ImageTools ( { buildx} ) . create ( {
7272 sources : [ 'cwd://descriptor.json' , 'docker.io/library/alpine:latest' ] ,
73- tags : [ 'docker.io/user/app:latest' ]
73+ tags : [ 'docker.io/user/app:latest' ] ,
74+ silent : true
7475 } ) ;
7576
7677 expect ( getCommand ) . toHaveBeenCalledWith ( [ 'imagetools' , 'create' , '--tag' , 'docker.io/user/app:latest' , '--metadata-file' , metadataFile , '--file' , 'descriptor.json' , 'docker.io/library/alpine:latest' ] ) ;
@@ -104,7 +105,8 @@ describe('create', () => {
104105
105106 const result = await new ImageTools ( { buildx} ) . create ( {
106107 sources : [ 'docker.io/library/alpine:latest' ] ,
107- dryRun : true
108+ dryRun : true ,
109+ silent : true
108110 } ) ;
109111
110112 expect ( getCommand ) . toHaveBeenCalledWith ( [ 'imagetools' , 'create' , '--dry-run' , 'docker.io/library/alpine:latest' ] ) ;
@@ -114,4 +116,26 @@ describe('create', () => {
114116 } ) ;
115117 expect ( result ) . toBeUndefined ( ) ;
116118 } ) ;
119+
120+ it ( 'skips command execution when skipExec is enabled' , async ( ) => {
121+ const getCommand = vi . fn ( ) . mockResolvedValue ( {
122+ command : 'docker' ,
123+ args : [ 'buildx' , 'imagetools' , 'create' ]
124+ } ) ;
125+ const buildx = { getCommand} as unknown as Buildx ;
126+ const execSpy = vi . spyOn ( Exec , 'getExecOutput' ) . mockResolvedValue ( {
127+ exitCode : 0 ,
128+ stdout : '' ,
129+ stderr : ''
130+ } ) ;
131+
132+ const result = await new ImageTools ( { buildx} ) . create ( {
133+ sources : [ 'docker.io/library/alpine:latest' ] ,
134+ skipExec : true
135+ } ) ;
136+
137+ expect ( getCommand ) . toHaveBeenCalledWith ( [ 'imagetools' , 'create' , '--metadata-file' , metadataFile , 'docker.io/library/alpine:latest' ] ) ;
138+ expect ( execSpy ) . not . toHaveBeenCalled ( ) ;
139+ expect ( result ) . toBeUndefined ( ) ;
140+ } ) ;
117141} ) ;
0 commit comments