@@ -355,6 +355,8 @@ describe('config parser', () => {
355355 let jobParametersTemplate ;
356356 let providerTemplate ;
357357 let jobWithRequiresTemplate ;
358+ let jobWithCacheTemplate1 ;
359+ let jobWithCacheTemplate2 ;
358360
359361 beforeEach ( ( ) => {
360362 firstTemplate = JSON . parse ( loadData ( 'template.json' ) ) ;
@@ -367,6 +369,8 @@ describe('config parser', () => {
367369 jobParametersTemplate = JSON . parse ( loadData ( 'templateWithParameters.json' ) ) ;
368370 providerTemplate = JSON . parse ( loadData ( 'templateWithProvider.json' ) ) ;
369371 jobWithRequiresTemplate = JSON . parse ( loadData ( 'templateWithRequires.json' ) ) ;
372+ jobWithCacheTemplate1 = JSON . parse ( loadData ( 'templateWithCache.json' ) ) ;
373+ jobWithCacheTemplate2 = JSON . parse ( loadData ( 'templateWithCache.json' ) ) ;
370374 templateFactoryMock . getFullNameAndVersion . returns ( { isVersion : true } ) ;
371375 templateFactoryMock . getTemplate . withArgs ( 'mytemplate@1.2.3' ) . resolves ( firstTemplate ) ;
372376 templateFactoryMock . getTemplate . withArgs ( 'yourtemplate@2' ) . resolves ( secondTemplate ) ;
@@ -387,6 +391,14 @@ describe('config parser', () => {
387391 templateFactoryMock . getTemplate
388392 . withArgs ( 'JobTestNamespace/jobrequirestemplate@2' )
389393 . resolves ( jobWithRequiresTemplate ) ;
394+ // Since the resolved values are the same object, their properties can be overwritten during other parsing.
395+ // We need to separate that resolved values in tests.
396+ templateFactoryMock . getTemplate
397+ . withArgs ( 'TemplateCacheTestNamespace/cachetemplate@1' )
398+ . resolves ( jobWithCacheTemplate1 ) ;
399+ templateFactoryMock . getTemplate
400+ . withArgs ( 'TemplateCacheTestNamespace/cachetemplate@2' )
401+ . resolves ( jobWithCacheTemplate2 ) ;
390402 } ) ;
391403
392404 it ( 'flattens templates successfully' , ( ) =>
@@ -597,6 +609,15 @@ describe('config parser', () => {
597609 ) ;
598610 } ) ) ;
599611
612+ it ( 'flattens cache config with templates containing parsed cache setting' , ( ) =>
613+ parser ( {
614+ yaml : loadData ( 'basic-job-and-template-with-cache.yaml' ) ,
615+ templateFactory : templateFactoryMock ,
616+ triggerFactory
617+ } ) . then ( data => {
618+ assert . deepEqual ( data , JSON . parse ( loadData ( 'basic-job-and-template-with-cache.json' ) ) ) ;
619+ } ) ) ;
620+
600621 it ( 'flattens templates with provider' , ( ) =>
601622 parser ( {
602623 yaml : loadData ( 'basic-job-with-provider.yaml' ) ,
0 commit comments