everything after postClearCache

This commit is contained in:
Michael C
2021-09-16 23:05:16 -04:00
parent 7cef510b29
commit e7d55d1e1b
10 changed files with 482 additions and 542 deletions

View File

@@ -1,5 +1,5 @@
import fetch from "node-fetch";
import {Done, getbaseURL} from "../utils";
import {Done, getbaseURL, postJSON} from "../utils";
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import {IDatabase} from "../../src/databases/IDatabase";
@@ -32,9 +32,8 @@ async function dbSponsorTimesCompareExpect(db: IDatabase, videoId: string, expec
describe("postPurgeAllSegments", function () {
const privateVipUserID = "VIPUser-purgeAll";
const route = "/api/purgeAllSegments";
const vipUserID = getHash(privateVipUserID);
const baseURL = getbaseURL();
const endpoint = `${getbaseURL()}/api/purgeAllSegments`;
before(async function () {
// startTime and endTime get set in beforeEach for consistency
@@ -47,11 +46,8 @@ describe("postPurgeAllSegments", function () {
});
it("Reject non-VIP user", function (done: Done) {
fetch(`${baseURL}${route}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
fetch(endpoint, {
...postJSON,
body: JSON.stringify({
videoID: "vsegpurge01",
userID: "segshift_randomuser001",
@@ -65,11 +61,8 @@ describe("postPurgeAllSegments", function () {
});
it("Purge all segments success", function (done: Done) {
fetch(`${baseURL}${route}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
fetch(endpoint, {
...postJSON,
body: JSON.stringify({
videoID: "vsegpurge01",
userID: privateVipUserID,
@@ -83,12 +76,7 @@ describe("postPurgeAllSegments", function () {
});
it("Should return 400 if missing body", function (done: Done) {
fetch(`${baseURL}${route}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
}
})
fetch(endpoint, { ...postJSON })
.then(async res => {
assert.strictEqual(res.status, 400);
done();