mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
test(oc-path): remove duplicate scenario coverage (#130060)
Amp-Thread-ID: https://ampcode.com/threads/T-01a037b5-3918-749f-90bd-5c9ac1dced16 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
GitHub
parent
e3a3de0fe7
commit
235bf4c76f
@@ -13,22 +13,6 @@ function expectErr(fn: () => unknown, code: string): void {
|
||||
}
|
||||
|
||||
describe("oc-path-parse-edges", () => {
|
||||
it("file + section", () => {
|
||||
expect(parseOcPath("oc://SOUL.md/Boundaries").section).toBe("Boundaries");
|
||||
});
|
||||
|
||||
it("file + section + item", () => {
|
||||
expect(parseOcPath("oc://SOUL.md/Boundaries/deny-rule-1").item).toBe("deny-rule-1");
|
||||
});
|
||||
|
||||
it("file + section + item + field", () => {
|
||||
expect(parseOcPath("oc://SOUL.md/B/deny-1/risk").field).toBe("risk");
|
||||
});
|
||||
|
||||
it("session query parameter", () => {
|
||||
expect(parseOcPath("oc://X.md?session=daily").session).toBe("daily");
|
||||
});
|
||||
|
||||
it("session with full path", () => {
|
||||
const p = parseOcPath("oc://X.md/sec/item/field?session=cron");
|
||||
expect(p).toEqual({
|
||||
@@ -55,30 +39,10 @@ describe("oc-path-parse-edges", () => {
|
||||
expect(p.session).toBeUndefined();
|
||||
});
|
||||
|
||||
it("missing scheme throws", () => {
|
||||
expectErr(() => parseOcPath("SOUL.md"), "OC_PATH_MISSING_SCHEME");
|
||||
});
|
||||
|
||||
it("wrong scheme throws", () => {
|
||||
expectErr(() => parseOcPath("https://x.com"), "OC_PATH_MISSING_SCHEME");
|
||||
});
|
||||
|
||||
it("empty after scheme throws", () => {
|
||||
expectErr(() => parseOcPath("oc://"), "OC_PATH_EMPTY");
|
||||
});
|
||||
|
||||
it("empty segment throws", () => {
|
||||
expectErr(() => parseOcPath("oc://X.md//item"), "OC_PATH_EMPTY_SEGMENT");
|
||||
});
|
||||
|
||||
it("too-deep nesting throws", () => {
|
||||
expectErr(() => parseOcPath("oc://X.md/a/b/c/d/e"), "OC_PATH_TOO_DEEP");
|
||||
});
|
||||
|
||||
it("non-string throws", () => {
|
||||
expectErr(() => parseOcPath(42 as unknown as string), "OC_PATH_NOT_STRING");
|
||||
});
|
||||
|
||||
it("round-trip canonical forms", () => {
|
||||
const cases = [
|
||||
"oc://SOUL.md",
|
||||
@@ -112,14 +76,6 @@ describe("oc-path-parse-edges", () => {
|
||||
expect(p.item).toBe("name");
|
||||
});
|
||||
|
||||
it("formatOcPath rejects empty file", () => {
|
||||
expectErr(() => formatOcPath({ file: "" }), "OC_PATH_FILE_REQUIRED");
|
||||
});
|
||||
|
||||
it("formatOcPath rejects item without section", () => {
|
||||
expectErr(() => formatOcPath({ file: "X.md", item: "i" }), "OC_PATH_NESTING");
|
||||
});
|
||||
|
||||
it("formatOcPath quotes raw slot values containing special chars", () => {
|
||||
const constructed = formatOcPath({
|
||||
file: "config.jsonc",
|
||||
|
||||
@@ -3,22 +3,6 @@ import { describe, expect, it } from "vitest";
|
||||
import { OcEmitSentinelError, REDACTED_SENTINEL, guardSentinel } from "../sentinel.js";
|
||||
|
||||
describe("guardSentinel", () => {
|
||||
it("passes through normal strings", () => {
|
||||
expect(() => guardSentinel("normal value", "oc://SOUL.md")).not.toThrow();
|
||||
});
|
||||
|
||||
it("passes through non-string values", () => {
|
||||
expect(() => guardSentinel(42, "oc://SOUL.md")).not.toThrow();
|
||||
expect(() => guardSentinel(null, "oc://SOUL.md")).not.toThrow();
|
||||
expect(() => guardSentinel(undefined, "oc://SOUL.md")).not.toThrow();
|
||||
});
|
||||
|
||||
it("throws on the sentinel literal", () => {
|
||||
expect(() => guardSentinel(REDACTED_SENTINEL, "oc://SOUL.md/[fm]/token")).toThrow(
|
||||
OcEmitSentinelError,
|
||||
);
|
||||
});
|
||||
|
||||
it("attaches the OcPath in the error", () => {
|
||||
try {
|
||||
guardSentinel(REDACTED_SENTINEL, "oc://config/plugins.entries.foo.token");
|
||||
|
||||
Reference in New Issue
Block a user