@@ -121,6 +121,64 @@ describe('Configuring path parameter caching', () => {
121121 } ) ;
122122 } ) ;
123123
124+ describe ( 'when one endpoint has cache key parameters and a path parameter containing underscore' , ( ) => {
125+ let cacheKeyParameters , method ;
126+ let functionWithoutCachingName , functionWithCachingName ;
127+ before ( ( ) => {
128+ functionWithoutCachingName = 'list-all-cats' ;
129+ let functionWithoutCaching = given . a_serverless_function ( functionWithoutCachingName )
130+ . withHttpEndpoint ( 'get' , '/cats' ) ;
131+
132+ functionWithCachingName = 'get-cat-by-paw-id' ;
133+ cacheKeyParameters = [ { name : 'request.path.paw_id' } , { name : 'request.header.Accept-Language' } ] ;
134+ let functionWithCaching = given . a_serverless_function ( functionWithCachingName )
135+ . withHttpEndpoint ( 'get' , '/cat/{paw_id}' , { enabled : true , cacheKeyParameters } ) ;
136+
137+ serverless = given . a_serverless_instance ( serviceName )
138+ . withApiGatewayCachingConfig ( true , '0.5' , 45 )
139+ . forStage ( stage )
140+ . withFunction ( functionWithCaching )
141+ . withFunction ( functionWithoutCaching ) ;
142+
143+ when_configuring_path_parameters ( serverless ) ;
144+ } ) ;
145+
146+ describe ( 'on the method corresponding with the endpoint with cache key parameters' , ( ) => {
147+ before ( ( ) => {
148+ method = serverless . getMethodResourceForFunction ( functionWithCachingName ) ;
149+ } ) ;
150+
151+ it ( 'should configure them as request parameters' , ( ) => {
152+ for ( let parameter of cacheKeyParameters ) {
153+ expect ( method . Properties . RequestParameters )
154+ . to . deep . include ( {
155+ [ `method.${ parameter . name } ` ] : { }
156+ } ) ;
157+ }
158+ } ) ;
159+
160+ it ( 'should set integration request parameters' , ( ) => {
161+ for ( let parameter of cacheKeyParameters ) {
162+ expect ( method . Properties . Integration . RequestParameters )
163+ . to . deep . include ( {
164+ [ `integration.${ parameter . name } ` ] : `method.${ parameter . name } `
165+ } ) ;
166+ }
167+ } ) ;
168+
169+ it ( 'should set integration cache key parameters' , ( ) => {
170+ for ( let parameter of cacheKeyParameters ) {
171+ expect ( method . Properties . Integration . CacheKeyParameters )
172+ . to . include ( `method.${ parameter . name } ` ) ;
173+ }
174+ } ) ;
175+
176+ it ( 'should set a cache namespace' , ( ) => {
177+ expect ( method . Properties . Integration . CacheNamespace ) . to . exist ;
178+ } ) ;
179+ } ) ;
180+ } ) ;
181+
124182 describe ( 'when one endpoint has cache key parameters' , ( ) => {
125183 let cacheKeyParameters , functionWithCachingName ;
126184 before ( ( ) => {
0 commit comments