Skip to content

Commit

Permalink
[TECH] Ajouter les méthodes increment et decrement dans la méthode wi…
Browse files Browse the repository at this point in the history
…thPrefix de Redis (PIX-14936) (#10367)
  • Loading branch information
Alexandre-Monney authored Oct 21, 2024
1 parent 6c394bc commit 8788cde
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ class TemporaryStorage {
return storage.expire({ key: prefix + key, expirationDelaySeconds });
},

increment(key) {
return storage.increment({ key: prefix + key });
},

decrement(key) {
return storage.decrement({ key: prefix + key });
},

ttl(key) {
return storage.ttl(key);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ describe('Unit | Infrastructure | temporary-storage | TemporaryStorage', functio
get = sinon.stub();
delete = sinon.stub();
keys = sinon.stub();
increment = sinon.stub();
decrement = sinon.stub();
}

storage = new TestStorage();
Expand Down Expand Up @@ -116,6 +118,32 @@ describe('Unit | Infrastructure | temporary-storage | TemporaryStorage', functio
});
});

describe('#increment', function () {
it('should increment value of prefixed key', async function () {
// given
storage.increment.withArgs('a-prefix:a-key').resolves();

// when
await prefixedStorage.increment('a-key');

// then
expect(storage.increment).to.have.been.called;
});
});

describe('#decrement', function () {
it('should decrement value of prefixed key', async function () {
// given
storage.decrement.withArgs('a-prefix:a-key').resolves();

// when
await prefixedStorage.decrement('a-key');

// then
expect(storage.decrement).to.have.been.called;
});
});

describe('#delete', function () {
it('should delete a prefixed key', async function () {
// when
Expand Down

0 comments on commit 8788cde

Please sign in to comment.