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