Skip to content

Commit

Permalink
Get tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
stwiname committed Oct 15, 2024
1 parent fc80732 commit f42b21d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/bundle_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Deno.test("Generates a bundle", async () => {
Deno.test("Publishing a project to ipfs", async () => {
// WebWorkers don't work in tests, use the unsafe sandbox instead
const cid = await publishProject(
"./subquery-delegator/index.ts",
"./subquery-delegator/project.ts",
new IPFSClient(
Deno.env.get("IPFS_ENDPOINT") ??
"https://unauthipfs.subquery.network/ipfs/api/v0",
Expand Down
12 changes: 8 additions & 4 deletions src/loader_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,28 @@ const ipfs = new IPFSClient(
);

Deno.test("Load vector storage from dir", async () => {
const dbPath = await pullContent("./.db", ipfs, "");
const [dbPath, source] = await pullContent("./.db", ipfs, "");

expect(dbPath).toBe(resolve("./.db"));
expect(source).toBe("local");
});

Deno.test("Load vector storage from cloud storage", async () => {
const [dbPath] = await pullContent(
const [dbPath, source] = await pullContent(
"s3://my-bucket/lancedb",
ipfs,
"",
);

expect(dbPath).toBe("s3://my-bucket/lancedb");
expect(source).toBe("remote");
});

Deno.test("Load vector storage from LanceDB cloud", async () => {
const [dbPath] = await pullContent("db://my_database", ipfs, "");
const [dbPath, source] = await pullContent("db://my_database", ipfs, "");

expect(dbPath).toBe("db://my_database");
expect(source).toBe("remote");
});

Deno.test("Load vector storage from IPFS", async () => {
Expand All @@ -42,7 +45,7 @@ Deno.test("Load vector storage from IPFS", async () => {
],
} as unknown as IPFSClient;

const [dbPath] = await pullContent(
const [dbPath, source] = await pullContent(
"ipfs://QmbSzrfrgexP4Fugys356MYmWf3Wvk7kfEMaMNXrDXB2nd",
mockIpfs,
"",
Expand All @@ -51,6 +54,7 @@ Deno.test("Load vector storage from IPFS", async () => {
expect(dbPath).toBe(
resolve(getOSTempDir(), "QmbSzrfrgexP4Fugys356MYmWf3Wvk7kfEMaMNXrDXB2nd"),
);
expect(source).toBe("ipfs");

// Clean up
await Deno.remove(dbPath, { recursive: true });
Expand Down
7 changes: 6 additions & 1 deletion src/project/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ export async function loadProject(
entry: unknown,
config?: Record<string, string>,
): Promise<Project> {
Value.Assert(ProjectEntry, entry);
try {
Value.Assert(ProjectEntry, entry);
} catch (e) {
throw new Error("Project entry is invalid", { cause: e });
}

const cfg = loadRawConfigFromEnv(manifest.config, config);

const project = await entry(cfg);
Expand Down
4 changes: 2 additions & 2 deletions src/project/project_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Deno.test("handles an invalid entrypoint", async () => {
"Project entry is invalid",
);
await expect(loadProject({} as ProjectManifest, {})).rejects.toThrow(
"Expected union value",
); // TODO return better error message
"Project entry is invalid",
);
});

Deno.test("handles an invalid conifg", async () => {
Expand Down
1 change: 1 addition & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function SpinnerLog(
return async function (...args: unknown[]) {
const spinner = getSpinner().start(messages.start);
try {
// @ts-ignore need to apply this function call but unable to type "this"
const v = await fn.apply(this, ...args);
spinner.succeed(messages.success);
return v;
Expand Down

0 comments on commit f42b21d

Please sign in to comment.