Initial import of streamline
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { aggregateTtkbPackages } from "../src/ttkb_pool";
|
||||
import type { TtkbPackageInfo } from "../src/types";
|
||||
|
||||
function pkg(version: string, commitId: string): TtkbPackageInfo {
|
||||
return {
|
||||
id: "lemon8/lemon8-knowledge",
|
||||
version,
|
||||
commitId,
|
||||
description: "Lemon8 knowledge",
|
||||
skills: ["lemon8-knowledge-query"],
|
||||
};
|
||||
}
|
||||
|
||||
describe("aggregateTtkbPackages", () => {
|
||||
test("ready only when every eligible node reports the same revision", () => {
|
||||
const [option] = aggregateTtkbPackages([[pkg("1", "a")], [pkg("1", "a")]], 0);
|
||||
expect(option.ready).toBe(true);
|
||||
expect(option.partial).toBe(false);
|
||||
expect(option.availableNodes).toBe(2);
|
||||
expect(option.totalNodes).toBe(2);
|
||||
});
|
||||
|
||||
test("a silent older satellite makes the package partial, not guaranteed", () => {
|
||||
const [option] = aggregateTtkbPackages([[pkg("1", "a")]], 1);
|
||||
expect(option.ready).toBe(false);
|
||||
expect(option.partial).toBe(true);
|
||||
expect(option.totalNodes).toBe(2);
|
||||
});
|
||||
|
||||
test("revision drift is visible and not selectable", () => {
|
||||
const [option] = aggregateTtkbPackages([[pkg("1", "a")], [pkg("2", "b")]], 0);
|
||||
expect(option.ready).toBe(false);
|
||||
expect(option.consistent).toBe(false);
|
||||
expect(option.versions).toEqual(["1", "2"]);
|
||||
expect(option.commitIds).toEqual(["a", "b"]);
|
||||
});
|
||||
|
||||
test("package absent from one reporting node is partial", () => {
|
||||
const [option] = aggregateTtkbPackages([[pkg("1", "a")], []], 0);
|
||||
expect(option.ready).toBe(false);
|
||||
expect(option.availableNodes).toBe(1);
|
||||
expect(option.totalNodes).toBe(2);
|
||||
});
|
||||
|
||||
test("packages without revision metadata are not promised as identical", () => {
|
||||
const unknown = pkg("", "");
|
||||
const [option] = aggregateTtkbPackages([[unknown], [unknown]], 0);
|
||||
expect(option.ready).toBe(false);
|
||||
expect(option.consistent).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user