Skip to content

Commit

Permalink
api: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
victorges committed Apr 25, 2024
1 parent 5ad3303 commit 10eea44
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions packages/api/src/store/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,6 @@ async function ensureDatabase(postgresUrl: string) {
pool.end();
adminPool.end();
}

export const db = new DB();
export const jobsDb = new DB();
2 changes: 1 addition & 1 deletion packages/api/src/store/experiment-table.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sql from "sql-template-strings";

import { Experiment } from "../schema/types";
import { db } from ".";
import { db } from "./db";
import { ForbiddenError, NotFoundError } from "./errors";
import Table from "./table";
import { WithID } from "./types";
Expand Down
5 changes: 2 additions & 3 deletions packages/api/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Model from "./model";
import { DB, PostgresParams } from "./db";
import { db, jobsDb, DB, PostgresParams } from "./db";

export const db = new DB();
export const jobsDb = new DB();
export { db, jobsDb };

// Helper function to start database and boot up legacy store
export default async function makeStore(
Expand Down
7 changes: 3 additions & 4 deletions packages/api/src/webhooks/cannon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ describe("webhook cannon", () => {
expect(callCount).toBe(1);
expect(receivedEvent).toBe("stream.started");

// at this point the semaphore is re-acquired cause we just waited (acquired) above

sem = semaphore();
await server.queue.publishWebhook("events.stream.idle", {
type: "webhook_event",
id: "webhook_test_42",
Expand All @@ -302,6 +301,7 @@ describe("webhook cannon", () => {
expect(receivedEvent).toBe("stream.idle");

// does not receive some random event
sem = semaphore();
await server.queue.publishWebhook("events.stream.unknown" as any, {
type: "webhook_event",
id: "webhook_test_93",
Expand All @@ -311,8 +311,7 @@ describe("webhook cannon", () => {
userId: nonAdminUser.id,
});

const err = await sem.wait(1000).catch((err) => err);
expect(err?.message).toBe("timeout");
await sem.wait(1000);
expect(callCount).toBe(2);
});

Expand Down

0 comments on commit 10eea44

Please sign in to comment.