100% code coverage
mcollina opened this issue · comments
As titled, this module would benefit for 100% code coverage
Hi, I'm working on this task currently and it doesn't seems that if (cacheValue) return cacheValue
(SerializerManager.js line 22) is ever true.
Any idea how I could make this happen?
I think you would be ok in calling the same route twice on the same instance. Have you tried that?
Yes, I gave it a go and it looks like it's still not covering the line
t.test('application/yaml -> yaml', t => {
t.plan(6)
fastify.inject({
method: 'GET',
url: '/request',
payload: {},
headers: {
accept: 'application/yaml'
}
}, (err, res) => {
t.error(err)
t.strictDeepEqual(res.headers['content-type'], 'application/yaml')
t.strictDeepEqual(res.payload, YAML.stringify({ pippo: 'pluto' }))
})
fastify.inject({
method: 'GET',
url: '/request',
payload: {},
headers: {
accept: 'application/yaml'
}
}, (err, res) => {
t.error(err)
t.strictDeepEqual(res.headers['content-type'], 'application/yaml')
t.strictDeepEqual(res.payload, YAML.stringify({ pippo: 'pluto' }))
})
})
I'm, for now, trying to make it trigger, I'll write proper test when I'll finally be able to
They might need to be nested
If I am not wrong, the cache in this plugin will never be fired.
The main reason is that SerializerManager.expand
always initialize a new instance and for the preHandler
hook which call the SerializerManager.expand
will lead to always having new cache for each route.
As a result, calling same route multiple times or nesting will not trigger the cache.
As a result, calling same route multiple times or nesting will not trigger the cache.
This seems a bug to me!