Skip to content

Commit de75b41

Browse files
author
Wolfgang Frank
committed
added test to cover ST memory code
1 parent 2907567 commit de75b41

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/apicache_test.js

+25
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,31 @@ describe('Redis support', function() {
719719
.get('/api/movies')
720720
.expect(200, movies)
721721
})
722+
723+
it('properly caches with short-term cache', function() {
724+
var db = redis.createClient()
725+
var app = mockAPI.create('10 seconds', { redisClient: db, shortTermMemory: '20 ms', debug: true })
726+
727+
return request(app)
728+
.get('/api/movies')
729+
.expect(200, movies)
730+
.then(function(res) {
731+
expect(res.headers['apicache-store']).to.be.undefined
732+
expect(res.headers['apicache-version']).to.be.undefined
733+
expect(app.requestsProcessed).to.equal(1)
734+
})
735+
.then(function() {
736+
return request(app)
737+
.get('/api/movies')
738+
.expect(200, movies)
739+
.expect('apicache-store', 'redis')
740+
.expect('apicache-version', pkg.version)
741+
.then(assertNumRequestsProcessed(app, 1))
742+
.then(function() {
743+
db.flushdb()
744+
})
745+
})
746+
})
722747
})
723748
})
724749
})

0 commit comments

Comments
 (0)