mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 21:17:15 +03:00
everything up to purgeAllSegments
This commit is contained in:
@@ -4,16 +4,19 @@ import {db} from "../../src/databases/databases";
|
||||
import {getHash} from "../../src/utils/getHash";
|
||||
import assert from "assert";
|
||||
|
||||
const VIPUser = "clearCacheVIP";
|
||||
const regularUser = "regular-user";
|
||||
|
||||
describe("postClearCache", () => {
|
||||
before(async () => {
|
||||
await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES ('${getHash("clearing-vip")}')`);
|
||||
const startOfQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "UUID", "userID", "timeSubmitted", views, category, "shadowHidden", "hashedVideoID") VALUES';
|
||||
await db.prepare("run", `${startOfQuery}('clear-test', 0, 1, 2, 'clear-uuid', 'testman', 0, 50, 'sponsor', 0, '" + getHash("clear-test", 1) + "')`);
|
||||
await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES ('${getHash(VIPUser)}')`);
|
||||
const startOfQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "UUID", "userID", "timeSubmitted", "views", "category", "shadowHidden") VALUES';
|
||||
await db.prepare("run", `${startOfQuery}('clear-test', 0, 1, 2, 'clear-uuid', 'testman', 0, 50, 'sponsor', 0)`);
|
||||
});
|
||||
|
||||
it("Should be able to clear cache for existing video", (done: Done) => {
|
||||
fetch(`${getbaseURL()
|
||||
}/api/clearCache?userID=clearing-vip&videoID=clear-test`, {
|
||||
}/api/clearCache?userID=${VIPUser}&videoID=clear-test`, {
|
||||
method: "POST"
|
||||
})
|
||||
.then(res => {
|
||||
@@ -25,7 +28,7 @@ describe("postClearCache", () => {
|
||||
|
||||
it("Should be able to clear cache for nonexistent video", (done: Done) => {
|
||||
fetch(`${getbaseURL()
|
||||
}/api/clearCache?userID=clearing-vip&videoID=dne-video`, {
|
||||
}/api/clearCache?userID=${VIPUser}&videoID=dne-video`, {
|
||||
method: "POST"
|
||||
})
|
||||
.then(res => {
|
||||
@@ -37,7 +40,7 @@ describe("postClearCache", () => {
|
||||
|
||||
it("Should get 403 as non-vip", (done: Done) => {
|
||||
fetch(`${getbaseURL()
|
||||
}/api/clearCache?userID=regular-user&videoID=clear-tes`, {
|
||||
}/api/clearCache?userID=${regularUser}&videoID=clear-tes`, {
|
||||
method: "POST"
|
||||
})
|
||||
.then(async res => {
|
||||
@@ -49,7 +52,7 @@ describe("postClearCache", () => {
|
||||
|
||||
it("Should give 400 with missing videoID", (done: Done) => {
|
||||
fetch(`${getbaseURL()
|
||||
}/api/clearCache?userID=clearing-vip`, {
|
||||
}/api/clearCache?userID=${VIPUser}`, {
|
||||
method: "POST"
|
||||
})
|
||||
.then(async res => {
|
||||
@@ -61,7 +64,7 @@ describe("postClearCache", () => {
|
||||
|
||||
it("Should give 400 with missing userID", (done: Done) => {
|
||||
fetch(`${getbaseURL()
|
||||
}/api/clearCache?userID=clearing-vip`, {
|
||||
}/api/clearCache?userID=${VIPUser}`, {
|
||||
method: "POST"
|
||||
})
|
||||
.then(async res => {
|
||||
|
||||
Reference in New Issue
Block a user