Skip to content

Commit

Permalink
feat: implement nodes method in cluster mock (#1260)
Browse files Browse the repository at this point in the history
  • Loading branch information
egmzy authored Mar 28, 2023
1 parent 40c5aed commit 7224f09
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,20 @@ RedisMock.Cluster = class RedisClusterMock extends RedisMock {
} else {
super()
}
this.nodes = []
nodesOptions.forEach(options => this.nodes.push(new RedisMock(options)))
nodesOptions.forEach(options => this.clusterNodes.all.push(new RedisMock(options)))
}

clusterNodes = {
all: [],
master: [],
slave: [],
};

nodes(role = "all") {
if (role !== 'all' && role !== 'master' && role !== 'slave') {
throw new Error(`Invalid role "${role}". Expected "all", "master" or "slave"`);
}
return this.clusterNodes['all'] // temporary return all until implemented slave and master logic
}
}

Expand Down

0 comments on commit 7224f09

Please sign in to comment.