mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-07 16:30:52 +08:00
Chore: homepage tests (#6278)
This commit is contained in:
@@ -9,6 +9,10 @@ export default async function handler(req, res) {
|
||||
|
||||
const provider = Object.values(searchProviders).find(({ name }) => name === providerName);
|
||||
|
||||
if (!provider) {
|
||||
return res.json([query, []]);
|
||||
}
|
||||
|
||||
if (provider.name === "Custom") {
|
||||
const widgets = await widgetsFromConfig();
|
||||
const searchWidget = widgets.find((w) => w.type === "search");
|
||||
|
||||
@@ -33,12 +33,15 @@ function parseLonghornData(data) {
|
||||
scheduled,
|
||||
};
|
||||
});
|
||||
const total = nodes.reduce((summary, node) => ({
|
||||
available: summary.available + node.available,
|
||||
maximum: summary.maximum + node.maximum,
|
||||
reserved: summary.reserved + node.reserved,
|
||||
scheduled: summary.scheduled + node.scheduled,
|
||||
}));
|
||||
const total = nodes.reduce(
|
||||
(summary, node) => ({
|
||||
available: summary.available + node.available,
|
||||
maximum: summary.maximum + node.maximum,
|
||||
reserved: summary.reserved + node.reserved,
|
||||
scheduled: summary.scheduled + node.scheduled,
|
||||
}),
|
||||
{ available: 0, maximum: 0, reserved: 0, scheduled: 0 },
|
||||
);
|
||||
total.id = "total";
|
||||
nodes.push(total);
|
||||
return nodes;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import si from "systeminformation";
|
||||
|
||||
import createLogger from "utils/logger";
|
||||
|
||||
const logger = createLogger("resources");
|
||||
|
||||
const si = require("systeminformation");
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { type, target, interfaceName = "default" } = req.query;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export default async function handler(req, res) {
|
||||
return res.status(400).json({ error: "Invalid provider" });
|
||||
}
|
||||
|
||||
const providersInConfig = getSettings()?.providers;
|
||||
const providersInConfig = getSettings()?.providers ?? {};
|
||||
|
||||
let apiKey;
|
||||
Object.entries(providersInConfig).forEach(([key, val]) => {
|
||||
@@ -78,5 +78,6 @@ export default async function handler(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
/* c8 ignore next 2 -- provider validation above currently makes this unreachable */
|
||||
return res.status(400).json({ error: "Invalid configuration" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user