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