Get tests running with SQL Server. Need to make them pass next.
This commit is contained in:
parent
186f916b40
commit
ce209a16b3
|
@ -41,13 +41,15 @@ tk.freeze(timestamp)
|
||||||
jest.setTimeout(99999999)
|
jest.setTimeout(99999999)
|
||||||
jest.unmock("mysql2")
|
jest.unmock("mysql2")
|
||||||
jest.unmock("mysql2/promise")
|
jest.unmock("mysql2/promise")
|
||||||
|
jest.unmock("mssql")
|
||||||
|
|
||||||
const { basicRow } = setup.structures
|
const { basicRow } = setup.structures
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
// ["internal", undefined],
|
// ["internal", undefined],
|
||||||
// ["postgres", databaseTestProviders.postgres],
|
// ["postgres", databaseTestProviders.postgres],
|
||||||
["mysql", databaseTestProviders.mysql],
|
// ["mysql", databaseTestProviders.mysql],
|
||||||
|
["mssql", databaseTestProviders.mssql],
|
||||||
])("/rows (%s)", (__, dsProvider) => {
|
])("/rows (%s)", (__, dsProvider) => {
|
||||||
const isInternal = !dsProvider
|
const isInternal = !dsProvider
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Datasource } from "@budibase/types"
|
||||||
import * as postgres from "./postgres"
|
import * as postgres from "./postgres"
|
||||||
import * as mongodb from "./mongodb"
|
import * as mongodb from "./mongodb"
|
||||||
import * as mysql from "./mysql"
|
import * as mysql from "./mysql"
|
||||||
|
import * as mssql from "./mssql"
|
||||||
import { StartedTestContainer } from "testcontainers"
|
import { StartedTestContainer } from "testcontainers"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
@ -14,4 +15,4 @@ export interface DatabaseProvider {
|
||||||
datasource(): Promise<Datasource>
|
datasource(): Promise<Datasource>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const databaseTestProviders = { postgres, mongodb, mysql }
|
export const databaseTestProviders = { postgres, mongodb, mysql, mssql }
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { Datasource, SourceName } from "@budibase/types"
|
||||||
|
import { GenericContainer, Wait, StartedTestContainer } from "testcontainers"
|
||||||
|
|
||||||
|
let container: StartedTestContainer | undefined
|
||||||
|
|
||||||
|
export async function start(): Promise<StartedTestContainer> {
|
||||||
|
return await new GenericContainer(
|
||||||
|
"mcr.microsoft.com/mssql/server:2022-latest"
|
||||||
|
)
|
||||||
|
.withExposedPorts(1433)
|
||||||
|
.withEnvironment({
|
||||||
|
ACCEPT_EULA: "Y",
|
||||||
|
MSSQL_SA_PASSWORD: "Password_123",
|
||||||
|
// This is important, as Microsoft allow us to use the "Developer" edition
|
||||||
|
// of SQL Server for development and testing purposes. We can't use other
|
||||||
|
// versions without a valid license, and we cannot use the Developer
|
||||||
|
// version in production.
|
||||||
|
MSSQL_PID: "Developer",
|
||||||
|
})
|
||||||
|
.withWaitStrategy(
|
||||||
|
Wait.forSuccessfulCommand(
|
||||||
|
"/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Password_123 -q 'SELECT 1'"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function datasource(): Promise<Datasource> {
|
||||||
|
if (!container) {
|
||||||
|
container = await start()
|
||||||
|
}
|
||||||
|
const host = container.getHost()
|
||||||
|
const port = container.getMappedPort(1433)
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: "datasource_plus",
|
||||||
|
source: SourceName.SQL_SERVER,
|
||||||
|
plus: true,
|
||||||
|
config: {
|
||||||
|
server: host,
|
||||||
|
port,
|
||||||
|
user: "sa",
|
||||||
|
password: "Password_123",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function stop() {
|
||||||
|
if (container) {
|
||||||
|
await container.stop()
|
||||||
|
container = undefined
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue