39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { mkdtemp, mkdir, writeFile } from "node:fs/promises";
|
|
|
|
import {
|
|
detectAssetShapeFromLocalPath,
|
|
probeLocalSourcePath,
|
|
} from "../src/runtime/local-source-probe.ts";
|
|
|
|
test("detect archive asset shape from local path", () => {
|
|
const result = detectAssetShapeFromLocalPath("/tmp/sample-data.zip");
|
|
|
|
assert.equal(result.type, "archive");
|
|
assert.equal(result.sourceType, "local_path");
|
|
assert.equal(result.displayName, "sample-data.zip");
|
|
});
|
|
|
|
test("probe local source path summarizes top-level entries and delivery recommendations", async () => {
|
|
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "emboflow-probe-"));
|
|
const deliveryRoot = path.join(tempRoot, "BJ_001_0001_OsmoNano_2026-03-19_14-51-43");
|
|
|
|
await mkdir(path.join(deliveryRoot, "DJI_001"), { recursive: true });
|
|
await writeFile(path.join(deliveryRoot, "meta.json"), "{}");
|
|
await writeFile(path.join(deliveryRoot, "video_meta.json"), "{}");
|
|
|
|
const summary = await probeLocalSourcePath({
|
|
sourcePath: deliveryRoot,
|
|
assetType: "folder",
|
|
displayName: path.basename(deliveryRoot),
|
|
});
|
|
|
|
assert.equal(summary.pathExists, true);
|
|
assert.match(summary.detectedFormats.join(","), /delivery_package/);
|
|
assert.ok(summary.topLevelPaths.includes("DJI_001"));
|
|
assert.ok(summary.recommendedNextNodes.includes("validate_structure"));
|
|
});
|