mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 12:07:07 +03:00
test fixes
test fixes - fix timeout in redis (by @ajayyy) - allow "errors" in tempVIP test - remove duplicate warning in postSkipSegments - remove duplicate VIP in tempVIP - run tests against different user once tempVIP removed - fix typo in getHashCache fetching syntax and wording - use standard syntax in redisTest - fix spacing in getLockReason - typo in npm script name test cases - add getHashCache test case - add more tests to redisTest configuration - update config to use redis timeout - update docker-compose to use newest pinned version Co-Authored-By: Ajay Ramachandran <dev@ajay.app>
This commit is contained in:
@@ -8,6 +8,8 @@ const genRandom = (bytes=8) => crypto.pseudoRandomBytes(bytes).toString("hex");
|
||||
const randKey1 = genRandom();
|
||||
const randValue1 = genRandom();
|
||||
const randKey2 = genRandom(16);
|
||||
const randKey3 = genRandom();
|
||||
const randValue3 = genRandom();
|
||||
|
||||
describe("redis test", function() {
|
||||
before(async function() {
|
||||
@@ -19,13 +21,41 @@ describe("redis test", function() {
|
||||
.then(res => {
|
||||
assert.strictEqual(res, randValue1);
|
||||
done();
|
||||
}).catch(err => assert.fail(err));
|
||||
}).catch(err => done(err));
|
||||
});
|
||||
it("Should not be able to get not stored value", (done) => {
|
||||
redis.get(randKey2)
|
||||
.then(res => {
|
||||
if (res) assert.fail("Value should not be found");
|
||||
if (res) done("Value should not be found");
|
||||
done();
|
||||
}).catch(err => assert.fail(err));
|
||||
}).catch(err => done(err));
|
||||
});
|
||||
it("Should be able to delete stored value", (done) => {
|
||||
redis.del(randKey1)
|
||||
.then(() => {
|
||||
redis.get(randKey1)
|
||||
.then(res => {
|
||||
assert.strictEqual(res, null);
|
||||
done();
|
||||
}).catch(err => done(err));
|
||||
}).catch(err => done(err));
|
||||
});
|
||||
it("Should be able to set expiring value", (done) => {
|
||||
redis.setEx(randKey3, 8400, randValue3)
|
||||
.then(() => {
|
||||
redis.get(randKey3)
|
||||
.then(res => {
|
||||
assert.strictEqual(res, randValue3);
|
||||
done();
|
||||
}).catch(err => done(err));
|
||||
}).catch(err => done(err));
|
||||
});
|
||||
it("Should continue when undefined value is fetched", (done) => {
|
||||
const undefkey = `undefined.${genRandom()}`;
|
||||
redis.get(undefkey)
|
||||
.then(result => {
|
||||
assert.ok(!result); // result should be falsy
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user