mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
adapters: remove runtime options, serve app always fresh to prevent race conditions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { TestRunner } from "core/test";
|
||||
import type { BkndConfig, DefaultArgs, FrameworkOptions, RuntimeOptions } from "./index";
|
||||
import type { BkndConfig, DefaultArgs } from "./index";
|
||||
import type { App } from "App";
|
||||
|
||||
export function adapterTestSuite<
|
||||
@@ -13,16 +13,8 @@ export function adapterTestSuite<
|
||||
label = "app",
|
||||
overrides = {},
|
||||
}: {
|
||||
makeApp: (
|
||||
config: Config,
|
||||
args?: Args,
|
||||
opts?: RuntimeOptions | FrameworkOptions,
|
||||
) => Promise<App>;
|
||||
makeHandler?: (
|
||||
config?: Config,
|
||||
args?: Args,
|
||||
opts?: RuntimeOptions | FrameworkOptions,
|
||||
) => (request: Request) => Promise<Response>;
|
||||
makeApp: (config: Config, args?: Args) => Promise<App>;
|
||||
makeHandler?: (config?: Config, args?: Args) => (request: Request) => Promise<Response>;
|
||||
label?: string;
|
||||
overrides?: {
|
||||
dbUrl?: string;
|
||||
@@ -30,7 +22,6 @@ export function adapterTestSuite<
|
||||
},
|
||||
) {
|
||||
const { test, expect, mock } = testRunner;
|
||||
const id = crypto.randomUUID();
|
||||
|
||||
test(`creates ${label}`, async () => {
|
||||
const beforeBuild = mock(async () => null) as any;
|
||||
@@ -53,7 +44,6 @@ export function adapterTestSuite<
|
||||
url: overrides.dbUrl ?? ":memory:",
|
||||
origin: "localhost",
|
||||
} as any,
|
||||
{ force: false, id },
|
||||
);
|
||||
expect(app).toBeDefined();
|
||||
expect(app.toJSON().server.cors.origin).toEqual("localhost");
|
||||
@@ -68,8 +58,8 @@ export function adapterTestSuite<
|
||||
return { res, data };
|
||||
};
|
||||
|
||||
test.skip("responds with the same app id", async () => {
|
||||
const fetcher = makeHandler(undefined, undefined, { force: false, id });
|
||||
/* test.skip("responds with the same app id", async () => {
|
||||
const fetcher = makeHandler(undefined, undefined, { id });
|
||||
|
||||
const { res, data } = await getConfig(fetcher);
|
||||
expect(res.ok).toBe(true);
|
||||
@@ -79,12 +69,12 @@ export function adapterTestSuite<
|
||||
|
||||
test.skip("creates fresh & responds to api config", async () => {
|
||||
// set the same id, but force recreate
|
||||
const fetcher = makeHandler(undefined, undefined, { id, force: true });
|
||||
const fetcher = makeHandler(undefined, undefined, { id });
|
||||
|
||||
const { res, data } = await getConfig(fetcher);
|
||||
expect(res.ok).toBe(true);
|
||||
expect(res.status).toBe(200);
|
||||
expect(data.server.cors.origin).toEqual("*");
|
||||
});
|
||||
}); */
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user