mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2026-01-27 12:50:47 +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:
@@ -6,14 +6,13 @@ import { client } from "../utils/httpClient";
|
||||
import { db, privateDB } from "../../src/databases/databases";
|
||||
import redis from "../../src/utils/redis";
|
||||
import assert from "assert";
|
||||
import { Logger } from "../../src/utils/logger";
|
||||
|
||||
// helpers
|
||||
const getSegment = (UUID: string) => db.prepare("get", `SELECT "votes", "locked", "category" FROM "sponsorTimes" WHERE "UUID" = ?`, [UUID]);
|
||||
|
||||
const permVIP1 = "tempVipPermOne";
|
||||
const permVIP1 = "tempVip_permaVIPOne";
|
||||
const publicPermVIP1 = getHash(permVIP1) as HashedUserID;
|
||||
const permVIP2 = "tempVipPermOne";
|
||||
const permVIP2 = "tempVip_permaVIPTwo";
|
||||
const publicPermVIP2 = getHash(permVIP2) as HashedUserID;
|
||||
|
||||
const tempVIPOne = "tempVipTempOne";
|
||||
@@ -51,15 +50,8 @@ const postVoteCategory = (userID: string, UUID: string, category: string) => cli
|
||||
category
|
||||
}
|
||||
});
|
||||
const checkUserVIP = async (publicID: HashedUserID) => {
|
||||
try {
|
||||
const reply = await redis.get(tempVIPKey(publicID));
|
||||
return reply;
|
||||
} catch (e) {
|
||||
Logger.error(e as string);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const checkUserVIP = async (publicID: HashedUserID): Promise<string> =>
|
||||
await redis.get(tempVIPKey(publicID));
|
||||
|
||||
describe("tempVIP test", function() {
|
||||
before(async function() {
|
||||
@@ -152,7 +144,7 @@ describe("tempVIP test", function() {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
it("Should be able to remove tempVIP prematurely", (done) => {
|
||||
addTempVIP("false", permVIP1, publicTempVIPOne, null)
|
||||
addTempVIP("false", permVIP1, publicTempVIPOne)
|
||||
.then(async res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const vip = await checkUserVIP(publicTempVIPOne);
|
||||
|
||||
Reference in New Issue
Block a user