Skip to content

Commit

Permalink
Add tokenizedId upsert test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Nov 19, 2024
1 parent 17f95fc commit e917c41
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/mocha/10-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Cache', function() {
});

describe('cache.upsert()', () => {
it('should insert and get a cache entry', async () => {
it('should add and get a cache entry', async () => {
const id = crypto.randomUUID();
const record1 = await cache.upsert({
id,
Expand Down Expand Up @@ -85,6 +85,20 @@ describe('Cache', function() {
}
err.message.should.include('Either "id" or "tokenizedId"');
});

it('should add using "tokenizedId"', async () => {
const id = crypto.randomUUID();
const {tokenizedId} = await cache.tokenizeId({id});
const record1 = await cache.upsert({
tokenizedId,
value: {},
ttl: 30000
});
const record2 = await cache.get({id});
record1.should.eql(record2);
const record3 = await cache.get({tokenizedId});
record2.should.eql(record3);
});
});

describe('cache.get()', () => {
Expand Down

0 comments on commit e917c41

Please sign in to comment.