mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Add test, Fix sql syntax
This commit is contained in:
parent
214ddc9807
commit
081f2d14b7
2 changed files with 5 additions and 4 deletions
|
@ -9,10 +9,10 @@ CREATE TABLE "sqlb_temp_table_17" (
|
|||
"reason" TEXT NOT NULL default ''
|
||||
);
|
||||
|
||||
INSERT INTO sqlb_temp_table_17 SELECT "userID","issueTime","issuerUserID","enabled", "" FROM "warnings";
|
||||
INSERT INTO sqlb_temp_table_17 SELECT "userID","issueTime","issuerUserID","enabled", '' FROM "warnings";
|
||||
|
||||
DROP TABLE warnings;
|
||||
ALTER TABLE sqlb_temp_table_17 RENAME TO "warnings";;
|
||||
ALTER TABLE sqlb_temp_table_17 RENAME TO "warnings";
|
||||
|
||||
UPDATE "config" SET value = 17 WHERE key = 'version';
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ describe('postWarning', () => {
|
|||
let json = {
|
||||
issuerUserID: 'warning-vip',
|
||||
userID: 'warning-0',
|
||||
reason: 'warning-reason-0'
|
||||
};
|
||||
fetch(getbaseURL()
|
||||
+ "/api/warnUser", {
|
||||
|
@ -23,8 +24,8 @@ describe('postWarning', () => {
|
|||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "userID", "issueTime", "issuerUserID", enabled FROM warnings WHERE "userID" = ?`, [json.userID]);
|
||||
if (row?.enabled == 1 && row?.issuerUserID == getHash(json.issuerUserID)) {
|
||||
let row = await db.prepare('get', `SELECT "userID", "issueTime", "issuerUserID", enabled, "reason" FROM warnings WHERE "userID" = ?`, [json.userID]);
|
||||
if (row?.enabled == 1 && row?.issuerUserID == getHash(json.issuerUserID) && row?.reason === json.reason) {
|
||||
done();
|
||||
} else {
|
||||
done("Warning missing from database");
|
||||
|
|
Loading…
Reference in a new issue