Respond to PR feedback.
This commit is contained in:
parent
871e1f3806
commit
1573242031
4 changed files with 27 additions and 55 deletions
|
@ -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")
|
||||
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()"`
|
||||
).withStartupTimeout(10000)
|
||||
Wait.forSuccessfulCommand(`mongosh --eval "db.version()"`)
|
||||
)
|
||||
.start()
|
||||
}
|
||||
return container
|
||||
}
|
||||
|
||||
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,8 +4,7 @@ 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")
|
||||
return await new GenericContainer("postgres:16.1-bullseye")
|
||||
.withExposedPorts(5432)
|
||||
.withEnvironment({ POSTGRES_PASSWORD: "password" })
|
||||
.withWaitStrategy(
|
||||
|
@ -14,12 +13,12 @@ export async function start(): Promise<StartedTestContainer> {
|
|||
).withStartupTimeout(10000)
|
||||
)
|
||||
.start()
|
||||
}
|
||||
return container
|
||||
}
|
||||
|
||||
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 a new issue