style: format tests and helpers
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
buildSandboxCreateArgs,
|
||||
type SandboxDockerConfig,
|
||||
} from "./sandbox.js";
|
||||
import { buildSandboxCreateArgs, type SandboxDockerConfig } from "./sandbox.js";
|
||||
|
||||
describe("buildSandboxCreateArgs", () => {
|
||||
it("includes hardening and resource flags", () => {
|
||||
|
||||
@@ -60,10 +60,7 @@ export type SandboxDockerConfig = {
|
||||
memory?: string | number;
|
||||
memorySwap?: string | number;
|
||||
cpus?: number;
|
||||
ulimits?: Record<
|
||||
string,
|
||||
string | number | { soft?: number; hard?: number }
|
||||
>;
|
||||
ulimits?: Record<string, string | number | { soft?: number; hard?: number }>;
|
||||
seccompProfile?: string;
|
||||
apparmorProfile?: string;
|
||||
dns?: string[];
|
||||
|
||||
@@ -219,7 +219,8 @@ describe("buildWorkspaceSkillsPrompt", () => {
|
||||
dir: path.join(skillsDir, "anybin-skill"),
|
||||
name: "anybin-skill",
|
||||
description: "Needs any bin",
|
||||
metadata: '{"clawdbot":{"requires":{"anyBins":["missingbin","fakebin"]}}}',
|
||||
metadata:
|
||||
'{"clawdbot":{"requires":{"anyBins":["missingbin","fakebin"]}}}',
|
||||
});
|
||||
await writeSkill({
|
||||
dir: path.join(skillsDir, "config-skill"),
|
||||
|
||||
@@ -289,7 +289,9 @@ function resolveClawdbotMetadata(
|
||||
const osRaw = normalizeStringList(clawdbotObj.os);
|
||||
return {
|
||||
always:
|
||||
typeof clawdbotObj.always === "boolean" ? clawdbotObj.always : undefined,
|
||||
typeof clawdbotObj.always === "boolean"
|
||||
? clawdbotObj.always
|
||||
: undefined,
|
||||
emoji:
|
||||
typeof clawdbotObj.emoji === "string" ? clawdbotObj.emoji : undefined,
|
||||
homepage:
|
||||
|
||||
@@ -83,7 +83,12 @@ describe("buildStatusMessage", () => {
|
||||
"./status.js"
|
||||
);
|
||||
|
||||
const storePath = path.join(dir, ".clawdbot", "sessions", "sessions.json");
|
||||
const storePath = path.join(
|
||||
dir,
|
||||
".clawdbot",
|
||||
"sessions",
|
||||
"sessions.json",
|
||||
);
|
||||
const sessionId = "sess-1";
|
||||
const logPath = path.join(
|
||||
dir,
|
||||
|
||||
@@ -21,7 +21,9 @@ describe("gateway server models + voicewake", () => {
|
||||
"voicewake.get returns defaults and voicewake.set broadcasts",
|
||||
{ timeout: 15_000 },
|
||||
async () => {
|
||||
const homeDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-home-"));
|
||||
const homeDir = await fs.mkdtemp(
|
||||
path.join(os.tmpdir(), "clawdbot-home-"),
|
||||
);
|
||||
const prevHome = process.env.HOME;
|
||||
process.env.HOME = homeDir;
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ function initSelfPresence() {
|
||||
const host = os.hostname();
|
||||
const ip = resolvePrimaryIPv4() ?? undefined;
|
||||
const version =
|
||||
process.env.CLAWDBOT_VERSION ?? process.env.npm_package_version ?? "unknown";
|
||||
process.env.CLAWDBOT_VERSION ??
|
||||
process.env.npm_package_version ??
|
||||
"unknown";
|
||||
const modelIdentifier = (() => {
|
||||
const p = os.platform();
|
||||
if (p === "darwin") {
|
||||
|
||||
@@ -91,7 +91,10 @@ describe("logger helpers", () => {
|
||||
});
|
||||
|
||||
function pathForTest() {
|
||||
const file = path.join(os.tmpdir(), `clawdbot-log-${crypto.randomUUID()}.log`);
|
||||
const file = path.join(
|
||||
os.tmpdir(),
|
||||
`clawdbot-log-${crypto.randomUUID()}.log`,
|
||||
);
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,11 @@ describe("web session", () => {
|
||||
|
||||
it("rotates creds backup when creds.json is valid JSON", async () => {
|
||||
const credsSuffix = path.join(".clawdbot", "credentials", "creds.json");
|
||||
const backupSuffix = path.join(".clawdbot", "credentials", "creds.json.bak");
|
||||
const backupSuffix = path.join(
|
||||
".clawdbot",
|
||||
"credentials",
|
||||
"creds.json.bak",
|
||||
);
|
||||
|
||||
const copySpy = vi
|
||||
.spyOn(fsSync, "copyFileSync")
|
||||
|
||||
Reference in New Issue
Block a user