- Auto-fix: import sorting, formatting (17 files) - Unsafe auto-fix: unused vars, template literals (7 files) - Manual: nursery/noConsole → suspicious/noConsole suppression - Manual: suppress noExcessiveCognitiveComplexity for cmdThreadResume and parseWorkflowPayload - Manual: remove unused destructured vars in current-role tests Closes #48
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
CROCKFORD_BASE32_ALPHABET,
|
||||
encodeCrockfordBase32Bits,
|
||||
decodeCrockfordBase32Bits,
|
||||
encodeUint64AsCrockford,
|
||||
decodeCrockfordToUint64,
|
||||
encodeCrockfordBase32Bits,
|
||||
encodeUint64AsCrockford,
|
||||
} from "../src/base32.js";
|
||||
|
||||
describe("CROCKFORD_BASE32_ALPHABET", () => {
|
||||
@@ -105,7 +105,7 @@ describe("encodeUint64AsCrockford / decodeCrockfordToUint64", () => {
|
||||
});
|
||||
|
||||
it("roundtrips arbitrary value", () => {
|
||||
const value = 0xDEAD_BEEF_CAFE_BABEn;
|
||||
const value = 0xdead_beef_cafe_baben;
|
||||
const encoded = encodeUint64AsCrockford(value);
|
||||
const decoded = decodeCrockfordToUint64(encoded);
|
||||
expect(decoded).toEqual({ ok: true, value });
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { assertValidLogTag } from '../src/process-logger/log-tag.js';
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { assertValidLogTag } from "../src/process-logger/log-tag.js";
|
||||
|
||||
describe('assertValidLogTag', () => {
|
||||
it('accepts valid 8-char Crockford Base32 tags', () => {
|
||||
expect(() => assertValidLogTag('0123ABCD')).not.toThrow();
|
||||
expect(() => assertValidLogTag('VWXYZ789')).not.toThrow();
|
||||
expect(() => assertValidLogTag('00000000')).not.toThrow();
|
||||
expect(() => assertValidLogTag('ZZZZZZZZ')).not.toThrow();
|
||||
describe("assertValidLogTag", () => {
|
||||
it("accepts valid 8-char Crockford Base32 tags", () => {
|
||||
expect(() => assertValidLogTag("0123ABCD")).not.toThrow();
|
||||
expect(() => assertValidLogTag("VWXYZ789")).not.toThrow();
|
||||
expect(() => assertValidLogTag("00000000")).not.toThrow();
|
||||
expect(() => assertValidLogTag("ZZZZZZZZ")).not.toThrow();
|
||||
});
|
||||
|
||||
it('accepts lowercase (converted via toUpperCase)', () => {
|
||||
expect(() => assertValidLogTag('abcdefgh')).not.toThrow();
|
||||
expect(() => assertValidLogTag('0a1b2c3d')).not.toThrow();
|
||||
it("accepts lowercase (converted via toUpperCase)", () => {
|
||||
expect(() => assertValidLogTag("abcdefgh")).not.toThrow();
|
||||
expect(() => assertValidLogTag("0a1b2c3d")).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws on too short', () => {
|
||||
expect(() => assertValidLogTag('1234567')).toThrow();
|
||||
expect(() => assertValidLogTag('')).toThrow();
|
||||
it("throws on too short", () => {
|
||||
expect(() => assertValidLogTag("1234567")).toThrow();
|
||||
expect(() => assertValidLogTag("")).toThrow();
|
||||
});
|
||||
|
||||
it('throws on too long', () => {
|
||||
expect(() => assertValidLogTag('123456789')).toThrow();
|
||||
it("throws on too long", () => {
|
||||
expect(() => assertValidLogTag("123456789")).toThrow();
|
||||
});
|
||||
|
||||
it('throws on invalid chars I, L, O, U', () => {
|
||||
expect(() => assertValidLogTag('IIIIIIII')).toThrow();
|
||||
expect(() => assertValidLogTag('LLLLLLLL')).toThrow();
|
||||
expect(() => assertValidLogTag('OOOOOOOO')).toThrow();
|
||||
expect(() => assertValidLogTag('UUUUUUUU')).toThrow();
|
||||
it("throws on invalid chars I, L, O, U", () => {
|
||||
expect(() => assertValidLogTag("IIIIIIII")).toThrow();
|
||||
expect(() => assertValidLogTag("LLLLLLLL")).toThrow();
|
||||
expect(() => assertValidLogTag("OOOOOOOO")).toThrow();
|
||||
expect(() => assertValidLogTag("UUUUUUUU")).toThrow();
|
||||
});
|
||||
|
||||
it('throws on special characters', () => {
|
||||
expect(() => assertValidLogTag('1234567!')).toThrow();
|
||||
expect(() => assertValidLogTag('ABCD-EFG')).toThrow();
|
||||
expect(() => assertValidLogTag('ABCD EFG')).toThrow();
|
||||
it("throws on special characters", () => {
|
||||
expect(() => assertValidLogTag("1234567!")).toThrow();
|
||||
expect(() => assertValidLogTag("ABCD-EFG")).toThrow();
|
||||
expect(() => assertValidLogTag("ABCD EFG")).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mergeRefsWithContentHash, normalizeRefsField } from '../src/refs-field.js';
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { mergeRefsWithContentHash, normalizeRefsField } from "../src/refs-field.js";
|
||||
|
||||
describe('mergeRefsWithContentHash', () => {
|
||||
it('appends a new content hash', () => {
|
||||
expect(mergeRefsWithContentHash(['a', 'b'], 'c')).toEqual(['a', 'b', 'c']);
|
||||
describe("mergeRefsWithContentHash", () => {
|
||||
it("appends a new content hash", () => {
|
||||
expect(mergeRefsWithContentHash(["a", "b"], "c")).toEqual(["a", "b", "c"]);
|
||||
});
|
||||
|
||||
it('skips duplicate content hash', () => {
|
||||
expect(mergeRefsWithContentHash(['a', 'b'], 'b')).toEqual(['a', 'b']);
|
||||
it("skips duplicate content hash", () => {
|
||||
expect(mergeRefsWithContentHash(["a", "b"], "b")).toEqual(["a", "b"]);
|
||||
});
|
||||
|
||||
it('preserves order', () => {
|
||||
expect(mergeRefsWithContentHash(['x', 'y'], 'z')).toEqual(['x', 'y', 'z']);
|
||||
it("preserves order", () => {
|
||||
expect(mergeRefsWithContentHash(["x", "y"], "z")).toEqual(["x", "y", "z"]);
|
||||
});
|
||||
|
||||
it('handles empty refs', () => {
|
||||
expect(mergeRefsWithContentHash([], 'a')).toEqual(['a']);
|
||||
it("handles empty refs", () => {
|
||||
expect(mergeRefsWithContentHash([], "a")).toEqual(["a"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizeRefsField', () => {
|
||||
it('returns empty array for non-array', () => {
|
||||
describe("normalizeRefsField", () => {
|
||||
it("returns empty array for non-array", () => {
|
||||
expect(normalizeRefsField(null)).toEqual([]);
|
||||
expect(normalizeRefsField(undefined)).toEqual([]);
|
||||
expect(normalizeRefsField(42)).toEqual([]);
|
||||
});
|
||||
|
||||
it('passes through string array', () => {
|
||||
expect(normalizeRefsField(['a', 'b'])).toEqual(['a', 'b']);
|
||||
it("passes through string array", () => {
|
||||
expect(normalizeRefsField(["a", "b"])).toEqual(["a", "b"]);
|
||||
});
|
||||
|
||||
it('filters non-strings from mixed array', () => {
|
||||
expect(normalizeRefsField(['a', 1, 'b', null])).toEqual(['a', 'b']);
|
||||
it("filters non-strings from mixed array", () => {
|
||||
expect(normalizeRefsField(["a", 1, "b", null])).toEqual(["a", "b"]);
|
||||
});
|
||||
|
||||
it('handles empty array', () => {
|
||||
it("handles empty array", () => {
|
||||
expect(normalizeRefsField([])).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ok, err } from '../src/result.js';
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { err, ok } from "../src/result.js";
|
||||
|
||||
describe('result', () => {
|
||||
describe('ok', () => {
|
||||
it('wraps a value', () => {
|
||||
describe("result", () => {
|
||||
describe("ok", () => {
|
||||
it("wraps a value", () => {
|
||||
const r = ok(42);
|
||||
expect(r).toEqual({ ok: true, value: 42 });
|
||||
});
|
||||
|
||||
it('wraps a string value', () => {
|
||||
const r = ok('hello');
|
||||
it("wraps a string value", () => {
|
||||
const r = ok("hello");
|
||||
expect(r.ok).toBe(true);
|
||||
if (r.ok) expect(r.value).toBe('hello');
|
||||
if (r.ok) expect(r.value).toBe("hello");
|
||||
});
|
||||
});
|
||||
|
||||
describe('err', () => {
|
||||
it('wraps an error', () => {
|
||||
const r = err('fail');
|
||||
expect(r).toEqual({ ok: false, error: 'fail' });
|
||||
describe("err", () => {
|
||||
it("wraps an error", () => {
|
||||
const r = err("fail");
|
||||
expect(r).toEqual({ ok: false, error: "fail" });
|
||||
});
|
||||
|
||||
it('wraps an Error object', () => {
|
||||
const e = new Error('boom');
|
||||
it("wraps an Error object", () => {
|
||||
const e = new Error("boom");
|
||||
const r = err(e);
|
||||
expect(r.ok).toBe(false);
|
||||
if (!r.ok) expect(r.error).toBe(e);
|
||||
});
|
||||
});
|
||||
|
||||
describe('type narrowing', () => {
|
||||
it('narrows ok result', () => {
|
||||
describe("type narrowing", () => {
|
||||
it("narrows ok result", () => {
|
||||
const r = ok(10) as ReturnType<typeof ok<number>> | ReturnType<typeof err<string>>;
|
||||
if (r.ok) {
|
||||
expect(r.value).toBe(10);
|
||||
@@ -39,10 +39,10 @@ describe('result', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('narrows err result', () => {
|
||||
const r = err('bad') as ReturnType<typeof ok<number>> | ReturnType<typeof err<string>>;
|
||||
it("narrows err result", () => {
|
||||
const r = err("bad") as ReturnType<typeof ok<number>> | ReturnType<typeof err<string>>;
|
||||
if (!r.ok) {
|
||||
expect(r.error).toBe('bad');
|
||||
expect(r.error).toBe("bad");
|
||||
} else {
|
||||
expect.unreachable();
|
||||
}
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { homedir } from 'node:os';
|
||||
import { getDefaultStorageRoot, getDefaultWorkflowStorageRoot, getGlobalCasDir } from '../src/storage-root.js';
|
||||
import { homedir } from "node:os";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
getDefaultStorageRoot,
|
||||
getDefaultWorkflowStorageRoot,
|
||||
getGlobalCasDir,
|
||||
} from "../src/storage-root.js";
|
||||
|
||||
describe('getDefaultStorageRoot', () => {
|
||||
it('returns homedir + /.uwf', () => {
|
||||
expect(getDefaultStorageRoot()).toBe(homedir() + '/.uwf');
|
||||
describe("getDefaultStorageRoot", () => {
|
||||
it("returns homedir + /.uwf", () => {
|
||||
expect(getDefaultStorageRoot()).toBe(`${homedir()}/.uwf`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getDefaultWorkflowStorageRoot', () => {
|
||||
it('returns same as getDefaultStorageRoot (deprecated alias)', () => {
|
||||
describe("getDefaultWorkflowStorageRoot", () => {
|
||||
it("returns same as getDefaultStorageRoot (deprecated alias)", () => {
|
||||
expect(getDefaultWorkflowStorageRoot()).toBe(getDefaultStorageRoot());
|
||||
});
|
||||
});
|
||||
|
||||
describe('getGlobalCasDir', () => {
|
||||
it('appends /cas to given storage root', () => {
|
||||
expect(getGlobalCasDir('/tmp/test')).toBe('/tmp/test/cas');
|
||||
describe("getGlobalCasDir", () => {
|
||||
it("appends /cas to given storage root", () => {
|
||||
expect(getGlobalCasDir("/tmp/test")).toBe("/tmp/test/cas");
|
||||
});
|
||||
|
||||
it('falls back to default when undefined', () => {
|
||||
expect(getGlobalCasDir(undefined)).toBe(homedir() + '/.uwf/cas');
|
||||
it("falls back to default when undefined", () => {
|
||||
expect(getGlobalCasDir(undefined)).toBe(`${homedir()}/.uwf/cas`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user