Respond to PR feedback.
This commit is contained in:
parent
871e1f3806
commit
1573242031
|
@ -6,7 +6,6 @@ import { MongoClient } from "mongodb"
|
|||
jest.unmock("mongodb")
|
||||
|
||||
describe("/queries", () => {
|
||||
let request = setup.getRequest()
|
||||
let config = setup.getConfig()
|
||||
let datasource: Datasource
|
||||
|
||||
|
@ -21,18 +20,7 @@ describe("/queries", () => {
|
|||
transformer: "return data",
|
||||
readable: true,
|
||||
}
|
||||
|
||||
const res = await request
|
||||
.post(`/api/queries`)
|
||||
.set(config.defaultHeaders())
|
||||
.send({ ...defaultQuery, ...query })
|
||||
.expect("Content-Type", /json/)
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error(JSON.stringify(res.body))
|
||||
}
|
||||
|
||||
return res.body as Query
|
||||
return await config.api.query.create({ ...defaultQuery, ...query })
|
||||
}
|
||||
|
||||
afterAll(async () => {
|
||||
|
|
|
@ -25,7 +25,6 @@ DROP TABLE test_table;
|
|||
`
|
||||
|
||||
describe("/queries", () => {
|
||||
let request = setup.getRequest()
|
||||
let config = setup.getConfig()
|
||||
let datasource: Datasource
|
||||
|
||||
|
@ -40,18 +39,7 @@ describe("/queries", () => {
|
|||
transformer: "return data",
|
||||
readable: true,
|
||||
}
|
||||
|
||||
const res = await request
|
||||
.post(`/api/queries`)
|
||||
.set(config.defaultHeaders())
|
||||
.send({ ...defaultQuery, ...query })
|
||||
.expect("Content-Type", /json/)
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error(JSON.stringify(res.body))
|
||||
}
|
||||
|
||||
return res.body as Query
|
||||
return await config.api.query.create({ ...defaultQuery, ...query })
|
||||
}
|
||||
|
||||
afterAll(async () => {
|
||||
|
|
|
@ -4,25 +4,22 @@ import { GenericContainer, Wait, StartedTestContainer } from "testcontainers"
|
|||
let container: StartedTestContainer | undefined
|
||||
|
||||
export async function start(): Promise<StartedTestContainer> {
|
||||
if (!container) {
|
||||
container = await new GenericContainer("mongo:7.0-jammy")
|
||||
.withExposedPorts(27017)
|
||||
.withEnvironment({
|
||||
MONGO_INITDB_ROOT_USERNAME: "mongo",
|
||||
MONGO_INITDB_ROOT_PASSWORD: "password",
|
||||
})
|
||||
.withWaitStrategy(
|
||||
Wait.forSuccessfulCommand(
|
||||
`mongosh --eval "db.version()"`
|
||||
).withStartupTimeout(10000)
|
||||
)
|
||||
.start()
|
||||
}
|
||||
return container
|
||||
return await new GenericContainer("mongo:7.0-jammy")
|
||||
.withExposedPorts(27017)
|
||||
.withEnvironment({
|
||||
MONGO_INITDB_ROOT_USERNAME: "mongo",
|
||||
MONGO_INITDB_ROOT_PASSWORD: "password",
|
||||
})
|
||||
.withWaitStrategy(
|
||||
Wait.forSuccessfulCommand(`mongosh --eval "db.version()"`)
|
||||
)
|
||||
.start()
|
||||
}
|
||||
|
||||
export async function datasource(): Promise<Datasource> {
|
||||
const container = await start()
|
||||
if (!container) {
|
||||
container = await start()
|
||||
}
|
||||
const host = container.getHost()
|
||||
const port = container.getMappedPort(27017)
|
||||
return {
|
||||
|
|
|
@ -4,22 +4,21 @@ import { GenericContainer, Wait, StartedTestContainer } from "testcontainers"
|
|||
let container: StartedTestContainer | undefined
|
||||
|
||||
export async function start(): Promise<StartedTestContainer> {
|
||||
if (!container) {
|
||||
container = await new GenericContainer("postgres:16.1-bullseye")
|
||||
.withExposedPorts(5432)
|
||||
.withEnvironment({ POSTGRES_PASSWORD: "password" })
|
||||
.withWaitStrategy(
|
||||
Wait.forSuccessfulCommand(
|
||||
"pg_isready -h localhost -p 5432"
|
||||
).withStartupTimeout(10000)
|
||||
)
|
||||
.start()
|
||||
}
|
||||
return container
|
||||
return await new GenericContainer("postgres:16.1-bullseye")
|
||||
.withExposedPorts(5432)
|
||||
.withEnvironment({ POSTGRES_PASSWORD: "password" })
|
||||
.withWaitStrategy(
|
||||
Wait.forSuccessfulCommand(
|
||||
"pg_isready -h localhost -p 5432"
|
||||
).withStartupTimeout(10000)
|
||||
)
|
||||
.start()
|
||||
}
|
||||
|
||||
export async function datasource(): Promise<Datasource> {
|
||||
const container = await start()
|
||||
if (!container) {
|
||||
container = await start()
|
||||
}
|
||||
const host = container.getHost()
|
||||
const port = container.getMappedPort(5432)
|
||||
|
||||
|
|
Loading…
Reference in New Issue