Initial Commit

This commit is contained in:
2026-05-27 23:47:53 +01:00
parent fbc70f96e6
commit 9b28db724f
18103 changed files with 1600554 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
import { describe, expect, it } from "@suaveplan/testing/runner";
import { GarageS3Fixture } from "./garage-s3-fixture.js";
describe("GarageS3Fixture — parseNodeId", () => {
class Exposed extends GarageS3Fixture {
parse(output: string) {
return this.parseNodeId(output);
}
}
it("parses valid status output", { timeout: 5000 }, () => {
const fixture = new Exposed();
const nodeId = fixture.parse(
"ID\tStatus\tAddr\nabc123def456 alive 127.0.0.1:3901\n"
);
expect(nodeId).toBe("abc123def456");
});
it("throws on empty string", { timeout: 5000 }, () => {
const fixture = new Exposed();
expect(() => fixture.parse("")).toThrow("no data rows found");
});
it("throws when only header lines present", { timeout: 5000 }, () => {
const fixture = new Exposed();
expect(() =>
fixture.parse("ID\tStatus\tAddr\n=== header ===\n")
).toThrow("no data rows found");
});
it("throws when data line starts with spaces (empty first token)", {
timeout: 5000,
}, () => {
const fixture = new Exposed();
// A non-blank line starting with spaces — passes filter, but split(/\s+/)[0] is ""
expect(() => fixture.parse("ID\tStatus\n abc123 alive\n")).toThrow(
"no data rows found"
);
});
});
describe("GarageS3Fixture — parseKeyInfo", () => {
class Exposed extends GarageS3Fixture {
parse(output: string) {
return this.parseKeyInfo(output);
}
}
it("parses valid key info output", { timeout: 5000 }, () => {
const fixture = new Exposed();
const result = fixture.parse(
"Key ID: GK1234567890\nSecret key: sk_abcdefghij\n"
);
expect(result.accessKeyId).toBe("GK1234567890");
expect(result.secretAccessKey).toBe("sk_abcdefghij");
});
it("throws when Key ID missing", { timeout: 5000 }, () => {
const fixture = new Exposed();
expect(() => fixture.parse("Secret key: sk_abcdefghij\n")).toThrow(
"Key ID"
);
});
it("throws when Secret key missing", { timeout: 5000 }, () => {
const fixture = new Exposed();
expect(() => fixture.parse("Key ID: GK1234567890\n")).toThrow(
"Secret key"
);
});
});