@@ -5,6 +5,7 @@ var assert = require('assert');
55
66var redisCache ;
77var customRedisCache ;
8+ var customRedisCache2 ;
89
910before ( function ( ) {
1011 redisCache = require ( 'cache-manager' ) . caching ( {
@@ -28,6 +29,19 @@ before(function () {
2829 return redisCache . store . isCacheableValue ( val ) ;
2930 }
3031 } ) ;
32+
33+ customRedisCache2 = require ( 'cache-manager' ) . caching ( {
34+ store : redisStore ,
35+ host : config . redis . host ,
36+ port : config . redis . port ,
37+ db : config . redis . db ,
38+ ttl : config . redis . ttl ,
39+ isCacheableValue : function ( val ) {
40+ // disallow FooBarString
41+ if ( val === 'FooBarString' ) return false ;
42+ return redisCache . store . isCacheableValue ( val ) ;
43+ }
44+ } ) ;
3145} ) ;
3246
3347describe ( 'initialization' , function ( ) {
@@ -137,6 +151,19 @@ describe('set', function () {
137151 } ) ;
138152 } ) ;
139153
154+ it ( 'should not store a value disallowed by isCacheableValue' , function ( done ) {
155+ assert . strictEqual ( customRedisCache2 . store . isCacheableValue ( 'FooBarString' ) , false ) ;
156+ customRedisCache2 . set ( 'foobar' , 'FooBarString' , function ( err ) {
157+ try {
158+ assert . notEqual ( err , null ) ;
159+ assert . equal ( err . message , 'value cannot be FooBarString' ) ;
160+ done ( ) ;
161+ } catch ( e ) {
162+ done ( e ) ;
163+ }
164+ } ) ;
165+ } ) ;
166+
140167} ) ;
141168
142169describe ( 'get' , function ( ) {
0 commit comments