Clean up correctly after Postgres integration tests.
This commit is contained in:
parent
e1af1a5be3
commit
0b8c829ed1
|
@ -1060,48 +1060,41 @@ describe("postgres integrations", () => {
|
||||||
describe("POST /api/datasources/:datasourceId/schema", () => {
|
describe("POST /api/datasources/:datasourceId/schema", () => {
|
||||||
let client: Client
|
let client: Client
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeEach(async () => {
|
||||||
client = new Client(
|
client = new Client(
|
||||||
(await databaseTestProviders.postgres.getDsConfig()).config!
|
(await databaseTestProviders.postgres.getDsConfig()).config!
|
||||||
)
|
)
|
||||||
await client.connect()
|
await client.connect()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterEach(async () => {
|
||||||
|
await client.query(`DROP TABLE IF EXISTS "table"`)
|
||||||
await client.end()
|
await client.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("recognises when a table has no primary key", async () => {
|
it("recognises when a table has no primary key", async () => {
|
||||||
await client.query(`
|
await client.query(`CREATE TABLE "table" (id SERIAL)`)
|
||||||
CREATE TABLE table_without_primary_key (
|
|
||||||
id SERIAL
|
|
||||||
)
|
|
||||||
`)
|
|
||||||
|
|
||||||
const response = await makeRequest(
|
const response = await makeRequest(
|
||||||
"post",
|
"post",
|
||||||
`/api/datasources/${postgresDatasource._id}/schema`
|
`/api/datasources/${postgresDatasource._id}/schema`
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(response.body.errors).toMatchObject({
|
expect(response.body.errors).toEqual({
|
||||||
table_without_primary_key: "Table must have a primary key.",
|
table: "Table must have a primary key.",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("recognises when a table is using a reserved column name", async () => {
|
it("recognises when a table is using a reserved column name", async () => {
|
||||||
await client.query(`
|
await client.query(`CREATE TABLE "table" (_id SERIAL PRIMARY KEY) `)
|
||||||
CREATE TABLE table_with_reserved_column_name (
|
|
||||||
_id SERIAL
|
|
||||||
)
|
|
||||||
`)
|
|
||||||
|
|
||||||
const response = await makeRequest(
|
const response = await makeRequest(
|
||||||
"post",
|
"post",
|
||||||
`/api/datasources/${postgresDatasource._id}/schema`
|
`/api/datasources/${postgresDatasource._id}/schema`
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(response.body.errors).toMatchObject({
|
expect(response.body.errors).toEqual({
|
||||||
table_without_primary_key: "Table must have a primary key.",
|
table: "Table contains invalid columns.",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue