@@ -21,6 +21,7 @@ describe('Docker Suite', function() {
2121 delete process . env [ shared . TestEnvVars . additionalImageTags ] ;
2222 delete process . env [ shared . TestEnvVars . enforceDockerNamingConvention ] ;
2323 delete process . env [ shared . TestEnvVars . memory ] ;
24+ delete process . env [ shared . TestEnvVars . addBaseImageData ] ;
2425 } ) ;
2526 after ( function ( ) {
2627 } ) ;
@@ -29,6 +30,7 @@ describe('Docker Suite', function() {
2930 let tp = path . join ( __dirname , 'TestSetup.js' ) ;
3031 let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
3132 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
33+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
3234 tr . run ( ) ;
3335
3436 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
@@ -44,6 +46,7 @@ describe('Docker Suite', function() {
4446 let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
4547 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
4648 process . env [ shared . TestEnvVars . memory ] = "2GB" ;
49+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
4750 tr . run ( ) ;
4851
4952 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
@@ -60,6 +63,7 @@ describe('Docker Suite', function() {
6063 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
6164 process . env [ shared . TestEnvVars . imageName ] = 'test/Te st:2' ;
6265 process . env [ shared . TestEnvVars . enforceDockerNamingConvention ] = 'true' ;
66+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
6367 tr . run ( ) ;
6468
6569 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
@@ -76,6 +80,7 @@ describe('Docker Suite', function() {
7680 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
7781 process . env [ shared . TestEnvVars . imageName ] = 'test/Te st:2' ;
7882 process . env [ shared . TestEnvVars . enforceDockerNamingConvention ] = 'false' ;
83+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
7984 tr . run ( ) ;
8085
8186 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
@@ -93,6 +98,7 @@ describe('Docker Suite', function() {
9398 process . env [ shared . TestEnvVars . imageName ] = 'test/Test:2' ;
9499 process . env [ shared . TestEnvVars . additionalImageTags ] = '6' ;
95100 process . env [ shared . TestEnvVars . enforceDockerNamingConvention ] = 'true' ;
101+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
96102 tr . run ( ) ;
97103
98104 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
@@ -109,6 +115,7 @@ describe('Docker Suite', function() {
109115 let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
110116 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
111117 process . env [ shared . TestEnvVars . includeLatestTag ] = "true" ;
118+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
112119 tr . run ( ) ;
113120
114121 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
@@ -168,6 +175,7 @@ describe('Docker Suite', function() {
168175 let tp = path . join ( __dirname , 'TestSetup.js' ) ;
169176 let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
170177 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . pushImage ;
178+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
171179 tr . run ( ) ;
172180
173181 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
@@ -211,6 +219,7 @@ describe('Docker Suite', function() {
211219 let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
212220 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
213221 process . env [ shared . TestEnvVars . containerType ] = shared . ContainerTypes . AzureContainerRegistry ;
222+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
214223 tr . run ( ) ;
215224
216225 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
@@ -227,10 +236,9 @@ describe('Docker Suite', function() {
227236 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
228237 process . env [ shared . TestEnvVars . containerType ] = shared . ContainerTypes . AzureContainerRegistry ;
229238 process . env [ shared . TestEnvVars . qualifyImageName ] = "true" ;
239+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
230240 tr . run ( ) ;
231241
232- //console.log(tr.stdout);
233-
234242 assert ( tr . invokedToolCount == 1 , 'should have invoked tool one times. actual: ' + tr . invokedToolCount ) ;
235243 assert ( tr . stderr . length == 0 || tr . errorIssues . length , 'should not have written to stderr' ) ;
236244 assert ( tr . succeeded , 'task should have succeeded' ) ;
@@ -243,6 +251,7 @@ describe('Docker Suite', function() {
243251 let tp = path . join ( __dirname , 'TestSetup.js' ) ;
244252 let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
245253 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
254+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
246255 tr . run ( ) ;
247256
248257 assert ( tr . succeeded , 'task should have succeeded' ) ;
@@ -255,6 +264,7 @@ describe('Docker Suite', function() {
255264 let tp = path . join ( __dirname , 'TestSetup.js' ) ;
256265 process . env [ shared . TestEnvVars . imageName ] = "testuser/standardbuild:11" ;
257266 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
267+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
258268 let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
259269 tr . run ( ) ;
260270
@@ -270,6 +280,38 @@ describe('Docker Suite', function() {
270280 let tp = path . join ( __dirname , 'TestSetup.js' ) ;
271281 process . env [ shared . TestEnvVars . imageName ] = "testuser/buildkit:11" ;
272282 process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
283+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
284+ let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
285+ tr . run ( ) ;
286+
287+ assert ( tr . invokedToolCount == 1 , 'should have invoked tool one time. actual: ' + tr . invokedToolCount ) ;
288+ assert ( tr . stderr . length == 0 || tr . errorIssues . length , 'should not have written to stderr' ) ;
289+ assert ( tr . succeeded , 'task should have succeeded' ) ;
290+ assert ( tr . stdout . indexOf ( "set DOCKER_TASK_BUILT_IMAGES=6c3ada3eb420" ) != - 1 , "docker build should have stored the image id." )
291+ console . log ( tr . stderr ) ;
292+ done ( ) ;
293+ } ) ;
294+
295+ it ( 'Docker build should add labels with base image info' , ( done :Mocha . Done ) => {
296+ let tp = path . join ( __dirname , 'TestSetup.js' ) ;
297+ process . env [ shared . TestEnvVars . imageName ] = "testuser/imagewithannotations:11" ;
298+ process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
299+ let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
300+ tr . run ( ) ;
301+
302+ assert ( tr . invokedToolCount == 3 , 'should have invoked tool three time. actual: ' + tr . invokedToolCount ) ;
303+ assert ( tr . stderr . length == 0 || tr . errorIssues . length , 'should not have written to stderr' ) ;
304+ assert ( tr . succeeded , 'task should have succeeded' ) ;
305+ assert ( tr . stdout . indexOf ( `[command]docker build -f ${ shared . formatPath ( "dir1/DockerFile" ) } -t testuser/imagewithannotations:11 ${ shared . DockerCommandArgs . BuildLabels } --label ${ shared . BaseImageLabels . name } --label ${ shared . BaseImageLabels . digest } ` ) != - 1 , "docker build should run" ) ;
306+ console . log ( tr . stderr ) ;
307+ done ( ) ;
308+ } ) ;
309+
310+ it ( 'Docker build should store the id of the image that was built with builkit.' , ( done :Mocha . Done ) => {
311+ let tp = path . join ( __dirname , 'TestSetup.js' ) ;
312+ process . env [ shared . TestEnvVars . imageName ] = "testuser/buildkit:11" ;
313+ process . env [ shared . TestEnvVars . action ] = shared . ActionTypes . buildImage ;
314+ process . env [ shared . TestEnvVars . addBaseImageData ] = "false" ;
273315 let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
274316 tr . run ( ) ;
275317
0 commit comments