mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 21:17:15 +03:00
everything to postClearCache
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
import assert from "assert";
|
||||
import fetch from "node-fetch";
|
||||
import { Done } from "../utils/utils";
|
||||
import { getbaseURL } from "../utils/getBaseURL";
|
||||
import {db} from "../../src/databases/databases";
|
||||
import { client } from "../utils/httpClient";
|
||||
let dbVersion: number;
|
||||
|
||||
describe("getStatus", () => {
|
||||
const endpoint = `${getbaseURL()}/api/status`;
|
||||
const endpoint = "/api/status";
|
||||
before(async () => {
|
||||
dbVersion = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
|
||||
});
|
||||
|
||||
it("Should be able to get status", (done: Done) => {
|
||||
fetch(endpoint)
|
||||
.then(async res => {
|
||||
it("Should be able to get status", (done) => {
|
||||
client.get(endpoint)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = await res.json();
|
||||
const data = res.data;
|
||||
assert.ok(data.uptime); // uptime should be greater than 1s
|
||||
assert.strictEqual(data.commit, "test");
|
||||
assert.strictEqual(data.db, Number(dbVersion));
|
||||
@@ -26,57 +24,52 @@ describe("getStatus", () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to get uptime only", (done: Done) => {
|
||||
fetch(`${endpoint}/uptime`)
|
||||
.then(async res => {
|
||||
it("Should be able to get uptime only", (done) => {
|
||||
client.get(`${endpoint}/uptime`)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = await res.text();
|
||||
assert.ok(Number(data) >= 1); // uptime should be greater than 1s
|
||||
assert.ok(Number(res.data) >= 1); // uptime should be greater than 1s
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to get commit only", (done: Done) => {
|
||||
fetch(`${endpoint}/commit`)
|
||||
.then(async res => {
|
||||
it("Should be able to get commit only", (done) => {
|
||||
client.get(`${endpoint}/commit`)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = await res.text();
|
||||
assert.strictEqual(data, "test"); // commit should be test
|
||||
assert.strictEqual(res.data, "test"); // commit should be test
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to get db only", (done: Done) => {
|
||||
fetch(`${endpoint}/db`)
|
||||
.then(async res => {
|
||||
it("Should be able to get db only", (done) => {
|
||||
client.get(`${endpoint}/db`)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = await res.text();
|
||||
assert.strictEqual(Number(data), Number(dbVersion)); // commit should be test
|
||||
assert.strictEqual(Number(res.data), Number(dbVersion)); // commit should be test
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to get startTime only", (done: Done) => {
|
||||
fetch(`${endpoint}/startTime`)
|
||||
.then(async res => {
|
||||
it("Should be able to get startTime only", (done) => {
|
||||
client.get(`${endpoint}/startTime`)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = await res.text();
|
||||
const now = Date.now();
|
||||
assert.ok(Number(data) <= now); // startTime should be more than now
|
||||
assert.ok(Number(res.data) <= now); // startTime should be more than now
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to get processTime only", (done: Done) => {
|
||||
fetch(`${endpoint}/processTime`)
|
||||
.then(async res => {
|
||||
it("Should be able to get processTime only", (done) => {
|
||||
client.get(`${endpoint}/processTime`)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = await res.text();
|
||||
assert.ok(Number(data) >= 0);
|
||||
assert.ok(Number(res.data) >= 0);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
|
||||
Reference in New Issue
Block a user