This commit is contained in:
Sam Rose 2024-11-05 15:13:34 +00:00
parent d1e83ce4f7
commit b2d80d7dcc
No known key found for this signature in database
2 changed files with 16 additions and 19 deletions

View File

@ -1,4 +1,7 @@
import { datasourceDescribe } from "../../../integrations/tests/utils" import {
DatabaseName,
datasourceDescribe,
} from "../../../integrations/tests/utils"
import tk from "timekeeper" import tk from "timekeeper"
import emitter from "../../../../src/events" import emitter from "../../../../src/events"
@ -81,11 +84,10 @@ async function waitForEvent(
} }
datasourceDescribe( datasourceDescribe(
{ name: "/rows (%s)" }, { name: "/rows (%s)", exclude: [DatabaseName.MONGODB] },
({ config, dsProvider, isInternal, isMSSQL, isOracle }) => { ({ config, dsProvider, isInternal, isMSSQL, isOracle }) => {
let datasource: Datasource | undefined let datasource: Datasource | undefined
let client: Knex | undefined let client: Knex | undefined
let table: Table let table: Table
beforeAll(async () => { beforeAll(async () => {

View File

@ -10,7 +10,7 @@ import { GenericContainer, StartedTestContainer } from "testcontainers"
import { testContainerUtils } from "@budibase/backend-core/tests" import { testContainerUtils } from "@budibase/backend-core/tests"
import cloneDeep from "lodash/cloneDeep" import cloneDeep from "lodash/cloneDeep"
import { Knex } from "knex" import { Knex } from "knex"
import TestConfiguration from "src/tests/utilities/TestConfiguration" import TestConfiguration from "../../../tests/utilities/TestConfiguration"
export type DatasourceProvider = () => Promise<Datasource | undefined> export type DatasourceProvider = () => Promise<Datasource | undefined>
@ -63,6 +63,8 @@ async function createDatasources(
config: TestConfiguration, config: TestConfiguration,
name: DatabaseName name: DatabaseName
): Promise<DatasourceDescribeReturnPromise> { ): Promise<DatasourceDescribeReturnPromise> {
await config.init()
const rawDatasource = await getDatasource(name) const rawDatasource = await getDatasource(name)
let datasource: Datasource | undefined let datasource: Datasource | undefined
@ -103,9 +105,14 @@ export function datasourceDescribe(
databases = databases.filter(db => !exclude.includes(db)) databases = databases.filter(db => !exclude.includes(db))
} }
const config = new TestConfiguration() describe.each(databases)(name, name => {
const prepped = databases.map(name => { const config = new TestConfiguration()
return {
afterAll(() => {
config.end()
})
cb({
name, name,
config, config,
dsProvider: createDatasources(config, name), dsProvider: createDatasources(config, name),
@ -116,19 +123,7 @@ export function datasourceDescribe(
isMongodb: name === DatabaseName.MONGODB, isMongodb: name === DatabaseName.MONGODB,
isMSSQL: name === DatabaseName.SQL_SERVER, isMSSQL: name === DatabaseName.SQL_SERVER,
isOracle: name === DatabaseName.ORACLE, isOracle: name === DatabaseName.ORACLE,
}
})
describe.each(prepped)(name, args => {
beforeAll(async () => {
await args.config.init()
}) })
afterAll(() => {
args.config.end()
})
cb(args)
}) })
} }