Closed jhonrocha closed 2 years ago
@simone-sanfratello There are 7 tests inside "invalidate" on async-cache-dedupe
. On this PR I covered the first 3. The other 4 test cases are directly related to the async-cache-dedupe
library, so I would need to use its instance to test methods like storage.store.smembers
.
For doing that, I believe I can use a stub. Is that the expectation here?
I would like to cover other cases instead, like policy~skip
, policy~extendKey
, skip
.
using an actual redis db, you can read what's inside and replicate the tests from async-cache-dedupe
, and of course feel free to add more tests!
Got it!! Working on that now. One more question, though: the clean way to run Redis is through a service, but that will limit the CI to a Linux runner. Is that okay?
Got it!! Working on that now. One more question, though: the clean way to run Redis is through a service, but that will limit the CI to a Linux runner. Is that okay?
yes, you can see an example on async-cache-dedupe
or fastify-redis
Got it. Simone, the invalidation function is async and it is not awaited, so I can only think in hackish ways to await for it to be executed. An example of the problem would be this:
// Request a mutation that clear 'gets' references
await app.inject({
...defaultPost,
body: { query: 'mutation { set(id: 11) }' }
})
// This fails, the invalidate was not called yet
t.equal((await redisClient.smembers('r:gets')).length, 0)
t.equal((await redisClient.smembers('r:get:11')).length, 0)
Do you think it is a good idea to add an event onInvalidate
to be called after invalidation ?
I have created a file for redis invalidation tests Closes #59