skip to Main Content

How to mock HashOperations of Spring StringRedisTemplate?

I'm writing unit test for my CacheService class: public class CacheService { private final HashOperations<String, String, String> redisHashOps; private final ValueOperations<String, String> valueOps; private final SetOperations<String, String> setOps; public CacheService(StringRedisTemplate redisTemplate) { this.redisHashOps = redisTemplate.opsForHash(); this.valueOps = redisTemplate.opsForValue(); this.setOps =…

VIEW QUESTION

Redis – Mocking Bull queues in NestJS

I am trying to test that after sending a request to one of my controllers, the queue pushes a job. The implementation itself works as expected. This is my app.module.ts @Module({ imports: [ HttpModule, TypeOrmModule.forRoot(typeOrmConfig), BullModule.forRoot({ redis: { host: redisConfig.host,…

VIEW QUESTION

Redis – Testing a function with a @cache.memoize gives PicklingError

I have some tests for functions that use cache, for example: Function: @retry(stop=stop_after_attempt(3)) @cache.cached(timeout=60, key_prefix='resouce_group_list') def get_azure_resource_groups(): data = [] resource_client = get_azure_resource_client() for item in resource_client.resource_groups.list(): data.append(item) return data Test: @patch("dev_maintenance.machines.get_azure_resource_client") def test_get_azure_list_rg(get_azure_resource_client): cache.clear() data = [] with app.app_context():…

VIEW QUESTION
Back To Top
Search