From b2d80d7dcc4473872c2c0fc55889461fb328a956 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Tue, 5 Nov 2024 15:13:34 +0000 Subject: [PATCH] wip --- .../server/src/api/routes/tests/row.spec.ts | 8 +++--- .../src/integrations/tests/utils/index.ts | 27 ++++++++----------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 4d53694412..5bd9e469e9 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1,4 +1,7 @@ -import { datasourceDescribe } from "../../../integrations/tests/utils" +import { + DatabaseName, + datasourceDescribe, +} from "../../../integrations/tests/utils" import tk from "timekeeper" import emitter from "../../../../src/events" @@ -81,11 +84,10 @@ async function waitForEvent( } datasourceDescribe( - { name: "/rows (%s)" }, + { name: "/rows (%s)", exclude: [DatabaseName.MONGODB] }, ({ config, dsProvider, isInternal, isMSSQL, isOracle }) => { let datasource: Datasource | undefined let client: Knex | undefined - let table: Table beforeAll(async () => { diff --git a/packages/server/src/integrations/tests/utils/index.ts b/packages/server/src/integrations/tests/utils/index.ts index e08fd90ac5..500ca0e8ef 100644 --- a/packages/server/src/integrations/tests/utils/index.ts +++ b/packages/server/src/integrations/tests/utils/index.ts @@ -10,7 +10,7 @@ import { GenericContainer, StartedTestContainer } from "testcontainers" import { testContainerUtils } from "@budibase/backend-core/tests" import cloneDeep from "lodash/cloneDeep" import { Knex } from "knex" -import TestConfiguration from "src/tests/utilities/TestConfiguration" +import TestConfiguration from "../../../tests/utilities/TestConfiguration" export type DatasourceProvider = () => Promise @@ -63,6 +63,8 @@ async function createDatasources( config: TestConfiguration, name: DatabaseName ): Promise { + await config.init() + const rawDatasource = await getDatasource(name) let datasource: Datasource | undefined @@ -103,9 +105,14 @@ export function datasourceDescribe( databases = databases.filter(db => !exclude.includes(db)) } - const config = new TestConfiguration() - const prepped = databases.map(name => { - return { + describe.each(databases)(name, name => { + const config = new TestConfiguration() + + afterAll(() => { + config.end() + }) + + cb({ name, config, dsProvider: createDatasources(config, name), @@ -116,19 +123,7 @@ export function datasourceDescribe( isMongodb: name === DatabaseName.MONGODB, isMSSQL: name === DatabaseName.SQL_SERVER, isOracle: name === DatabaseName.ORACLE, - } - }) - - describe.each(prepped)(name, args => { - beforeAll(async () => { - await args.config.init() }) - - afterAll(() => { - args.config.end() - }) - - cb(args) }) }