~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/atlibs

0
0
main
18 lines · 977 B Raw History
import assert from "node:assert/strict";
import { test } from "node:test";

import { did, load } from "../../../rust/src/harness.mjs";

const { handle } = await load(new URL("../../../target/wasm32-unknown-unknown/release/hello.wasm", import.meta.url), new URL("./module.json", import.meta.url));

// handle() runs the module under the real host loop; respond answers each call.
test("count lists records, then counts them", async () => {
	const ran = await handle("count", { collection: "xyz.statusphere.status" }, { respond: () => ({ ok: true, output: { records: [{}, {}] } }) });
	assert.equal(ran.calls[0].nsid, "com.atproto.repo.listRecords");
	assert.deepEqual(ran.result, { collection: "xyz.statusphere.status", records: 2 });
});

test("a failed call is the run's error", async () => {
	const ran = await handle("count", { collection: "xyz.statusphere.status" }, { respond: () => ({ ok: false, error: "RepoNotFound" }) });
	assert.match(ran.error, /RepoNotFound/);
});