1
1
import { GenericContainer } from "testcontainers"
2
2
import { generator } from "@budibase/backend-core/tests"
3
+ import { Duration , TemporalUnit } from "node-duration"
4
+
3
5
import postgres from "../../../integrations/postgres"
4
6
import mysql from "../../../integrations/mysql"
5
7
import couchdb from "../../../integrations/couchdb"
8
+ import { SourceName } from "@budibase/types"
9
+ import integrations from "../../../integrations"
6
10
7
11
jest . unmock ( "pg" )
8
12
jest . unmock ( "mysql2/promise" )
@@ -207,14 +211,24 @@ describe("datasource validators", () => {
207
211
208
212
let host : string , port : number
209
213
214
+ const password = "Str0Ng_p@ssW0rd!"
215
+
210
216
beforeAll ( async ( ) => {
211
217
const container = await new GenericContainer (
212
218
"mcr.microsoft.com/mssql/server"
213
219
)
214
220
. withExposedPorts ( 1433 )
215
221
. withEnv ( "ACCEPT_EULA" , "Y" )
216
- . withEnv ( "MSSQL_SA_PASSWORD" , "Str0Ng_p@ssW0rd!" )
222
+ . withEnv ( "MSSQL_SA_PASSWORD" , password )
217
223
. withEnv ( "MSSQL_PID" , "Developer" )
224
+ . withWaitStrategy ( Wait . forHealthCheck ( ) )
225
+ . withHealthCheck ( {
226
+ test : `/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${ password } " -Q "SELECT 1" -b -o /dev/null` ,
227
+ interval : new Duration ( 1000 , TemporalUnit . MILLISECONDS ) ,
228
+ timeout : new Duration ( 3 , TemporalUnit . SECONDS ) ,
229
+ retries : 20 ,
230
+ startPeriod : new Duration ( 100 , TemporalUnit . MILLISECONDS ) ,
231
+ } )
218
232
. start ( )
219
233
220
234
host = container . getContainerIpAddress ( )
@@ -224,7 +238,7 @@ describe("datasource validators", () => {
224
238
it ( "test valid connection string" , async ( ) => {
225
239
const result = await validator ( {
226
240
user : "sa" ,
227
- password : "Str0Ng_p@ssW0rd!" ,
241
+ password,
228
242
server : host ,
229
243
port : port ,
230
244
database : "master" ,
0 commit comments