mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-08 20:47:02 +03:00
add ignore clauses to tests
This commit is contained in:
@@ -14,7 +14,7 @@ export function userCounter(req: Request, res: Response, next: NextFunction): vo
|
|||||||
method: "post",
|
method: "post",
|
||||||
url: `${config.userCounterURL}/api/v1/addIP?hashedIP=${getIP(req)}`,
|
url: `${config.userCounterURL}/api/v1/addIP?hashedIP=${getIP(req)}`,
|
||||||
httpAgent
|
httpAgent
|
||||||
}).catch(() => Logger.debug(`Failing to connect to user counter at: ${config.userCounterURL}`));
|
}).catch(() => /* instanbul skip next */ Logger.debug(`Failing to connect to user counter at: ${config.userCounterURL}`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ export async function getSkipSegmentsByHash(req: Request, res: Response): Promis
|
|||||||
try {
|
try {
|
||||||
await getEtag("skipSegmentsHash", hashPrefix, service)
|
await getEtag("skipSegmentsHash", hashPrefix, service)
|
||||||
.then(etag => res.set("ETag", etag))
|
.then(etag => res.set("ETag", etag))
|
||||||
.catch(() => null);
|
.catch(/* istanbul ignore next */ () => null);
|
||||||
const output = Object.entries(segments).map(([videoID, data]) => ({
|
const output = Object.entries(segments).map(([videoID, data]) => ({
|
||||||
videoID,
|
videoID,
|
||||||
segments: data.segments,
|
segments: data.segments,
|
||||||
}));
|
}));
|
||||||
return res.status(output.length === 0 ? 404 : 200).json(output);
|
return res.status(output.length === 0 ? 404 : 200).json(output);
|
||||||
} catch(e) {
|
} catch (e) /* istanbul ignore next */ {
|
||||||
Logger.error(`skip segments by hash error: ${e}`);
|
Logger.error(`skip segments by hash error: ${e}`);
|
||||||
|
|
||||||
return res.status(500).send("Internal server error");
|
return res.status(500).send("Internal server error");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export function createMemoryCache(memoryFn: (...args: any[]) => void, cacheTimeMs: number): any {
|
export function createMemoryCache(memoryFn: (...args: any[]) => void, cacheTimeMs: number): any {
|
||||||
|
/* istanbul ignore if */
|
||||||
if (isNaN(cacheTimeMs)) cacheTimeMs = 0;
|
if (isNaN(cacheTimeMs)) cacheTimeMs = 0;
|
||||||
|
|
||||||
// holds the promise results
|
// holds the promise results
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const isUserTempVIP = async (hashedUserID: HashedUserID, videoID: VideoID
|
|||||||
try {
|
try {
|
||||||
const reply = await redis.get(tempVIPKey(hashedUserID));
|
const reply = await redis.get(tempVIPKey(hashedUserID));
|
||||||
return reply && reply == channelID;
|
return reply && reply == channelID;
|
||||||
} catch (e) {
|
} catch (e) /* istanbul ignore next */ {
|
||||||
Logger.error(e as string);
|
Logger.error(e as string);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class Logger {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
/* istanbul ignore if */
|
||||||
if (config.mode === "development") {
|
if (config.mode === "development") {
|
||||||
this._settings.INFO = true;
|
this._settings.INFO = true;
|
||||||
this._settings.DEBUG = true;
|
this._settings.DEBUG = true;
|
||||||
@@ -73,9 +74,11 @@ class Logger {
|
|||||||
|
|
||||||
let color = colors.Bright;
|
let color = colors.Bright;
|
||||||
if (level === LogLevel.ERROR) color = colors.FgRed;
|
if (level === LogLevel.ERROR) color = colors.FgRed;
|
||||||
|
/* istanbul ignore if */
|
||||||
if (level === LogLevel.WARN) color = colors.FgYellow;
|
if (level === LogLevel.WARN) color = colors.FgYellow;
|
||||||
|
|
||||||
let levelStr = level.toString();
|
let levelStr = level.toString();
|
||||||
|
/* istanbul ignore if */
|
||||||
if (levelStr.length === 4) {
|
if (levelStr.length === 4) {
|
||||||
levelStr += " "; // ensure logs are aligned
|
levelStr += " "; // ensure logs are aligned
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,17 +135,21 @@ if (config.redis?.enabled) {
|
|||||||
.then((reply) => resolve(reply))
|
.then((reply) => resolve(reply))
|
||||||
.catch((err) => reject(err))
|
.catch((err) => reject(err))
|
||||||
);
|
);
|
||||||
|
/* istanbul ignore next */
|
||||||
client.on("error", function(error) {
|
client.on("error", function(error) {
|
||||||
lastClientFail = Date.now();
|
lastClientFail = Date.now();
|
||||||
Logger.error(`Redis Error: ${error}`);
|
Logger.error(`Redis Error: ${error}`);
|
||||||
});
|
});
|
||||||
|
/* istanbul ignore next */
|
||||||
client.on("reconnect", () => {
|
client.on("reconnect", () => {
|
||||||
Logger.info("Redis: trying to reconnect");
|
Logger.info("Redis: trying to reconnect");
|
||||||
});
|
});
|
||||||
|
/* istanbul ignore next */
|
||||||
readClient?.on("error", function(error) {
|
readClient?.on("error", function(error) {
|
||||||
lastReadFail = Date.now();
|
lastReadFail = Date.now();
|
||||||
Logger.error(`Redis Read-Only Error: ${error}`);
|
Logger.error(`Redis Read-Only Error: ${error}`);
|
||||||
});
|
});
|
||||||
|
/* istanbul ignore next */
|
||||||
readClient?.on("reconnect", () => {
|
readClient?.on("reconnect", () => {
|
||||||
Logger.info("Redis Read-Only: trying to reconnect");
|
Logger.info("Redis Read-Only: trying to reconnect");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user