Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: ioredis-mock
node v15.14.0
endpoint
share
tweet
/** * https://github.com/OptimalBits/bull * */ require('ioredis/package.json'); const Queue = require("bull"); const RedisMock = require('ioredis-mock'); async function mockBullQ(){ //------------------------ const redisMock = new RedisMock(); redisMock.set('hello', '--->Testing: redis mock is working'); console.log(await redisMock.get('hello')); //------------------------ /** * * * I have no idea what client does, not sure what to return for this function * https://github.com/OptimalBits/bull/blob/088e5dfcbe9b5c347c2c8f5d9fca5c53c099bbe3/lib/worker.js * * Sample data passed to function: * key: "setname" * value: "bull:bW9ja2VkU" */ /* RedisMock.prototype.client = function(key,value){ this.set([key], value); this.status = 'ready'; console.log(`--> client() function called with --> key: "${key}" value: "${value}"`); return this; } */ function createClient(){ return new RedisMock(); } const queue = new Queue("mockedQueue",{createClient}); //Producer queue.add({ "name": "Moya Rich" }); //Worker queue.process(async (job) => { console.log("\n\n---job--->>>>>>>", job); }); } mockBullQ();
Created from: https://npm.runkit.com/ioredis-mock
Loading…
Clone and edit this document