mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 04:57:04 +03:00
add genUser frameworks, start fixing tests
transformative: - getUserID - redisTest - reputation mocha test reconfig: - etag - getIP - userCounter - validateVideoIDs
This commit is contained in:
15
test/utils/queryGen.ts
Normal file
15
test/utils/queryGen.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { IDatabase } from "../../src/databases/IDatabase";
|
||||
import { HashedUserID } from "../../src/types/user.model";
|
||||
import { usernameUserArray } from "./genUser";
|
||||
|
||||
export const insertUsername = async (db: IDatabase, userID: HashedUserID, userName: string, locked = false) => {
|
||||
const query = 'INSERT INTO "userNames" ("userID", "userName", "locked") VALUES(?, ?, ?)';
|
||||
const lockedValue = Number(locked);
|
||||
await db.prepare("run", query, [userID, userName, lockedValue]);
|
||||
};
|
||||
|
||||
export const insertUsernameBulk = async (db: IDatabase, users: usernameUserArray) => {
|
||||
const query = 'INSERT INTO "userNames" ("userID", "userName", "locked") VALUES(?, ?, ?)';
|
||||
for (const user of Object.values(users))
|
||||
await db.prepare("run", query, [user.pubID, user.username, 0]);
|
||||
};
|
||||
Reference in New Issue
Block a user