Adding negative test case for connections and adding test of table name fetching for postgres.
This commit is contained in:
parent
d85bcbc7e5
commit
38e39cf2f2
|
@ -163,9 +163,9 @@ export async function fetchTables(
|
|||
if (!connector.getTableNames) {
|
||||
ctx.throw(400, "Table name fetching not supported by datasource")
|
||||
}
|
||||
const tables = await connector.getTableNames()
|
||||
const tableNames = await connector.getTableNames()
|
||||
ctx.body = {
|
||||
tables,
|
||||
tableNames,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ jest.setTimeout(30000)
|
|||
|
||||
jest.unmock("pg")
|
||||
|
||||
describe("row api - postgres", () => {
|
||||
describe("postgres integrations", () => {
|
||||
let makeRequest: MakeRequestResponse,
|
||||
postgresDatasource: Datasource,
|
||||
primaryPostgresTable: Table,
|
||||
|
@ -443,19 +443,6 @@ describe("row api - postgres", () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe("POST /api/datasources/verify", () => {
|
||||
it("should be able to verify the connection", async () => {
|
||||
const config = pgDatasourceConfig()
|
||||
const response = await makeRequest(
|
||||
"post",
|
||||
"/api/datasources/verify",
|
||||
config
|
||||
)
|
||||
expect(response.status).toBe(200)
|
||||
expect(response.body.connected).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("DELETE /api/:tableId/rows", () => {
|
||||
const deleteRow = (
|
||||
tableId: string | undefined,
|
||||
|
@ -1041,4 +1028,43 @@ describe("row api - postgres", () => {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /api/datasources/verify", () => {
|
||||
it("should be able to verify the connection", async () => {
|
||||
const config = pgDatasourceConfig()
|
||||
const response = await makeRequest(
|
||||
"post",
|
||||
"/api/datasources/verify",
|
||||
config
|
||||
)
|
||||
expect(response.status).toBe(200)
|
||||
expect(response.body.connected).toBe(true)
|
||||
})
|
||||
|
||||
it("should state an invalid datasource cannot connect", async () => {
|
||||
const config = pgDatasourceConfig()
|
||||
config.datasource.config.password = "wrongpassword"
|
||||
const response = await makeRequest(
|
||||
"post",
|
||||
"/api/datasources/verify",
|
||||
config
|
||||
)
|
||||
expect(response.status).toBe(200)
|
||||
expect(response.body.connected).toBe(false)
|
||||
expect(response.body.error).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /api/datasources/:datasourceId/tables", () => {
|
||||
it("should fetch tables within postgres datasource", async () => {
|
||||
const primaryName = primaryPostgresTable.name
|
||||
const response = await makeRequest(
|
||||
"get",
|
||||
`/api/datasources/${postgresDatasource._id}/tables`
|
||||
)
|
||||
expect(response.status).toBe(200)
|
||||
expect(response.body.tableNames).toBeDefined()
|
||||
expect(response.body.tableNames.indexOf(primaryName)).not.toBe(-10)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -24,7 +24,7 @@ export interface VerifyDatasourceResponse {
|
|||
}
|
||||
|
||||
export interface FetchTablesDatasourceResponse {
|
||||
tables: string[]
|
||||
tableNames: string[]
|
||||
}
|
||||
|
||||
export interface UpdateDatasourceRequest extends Datasource {
|
||||
|
|
Loading…
Reference in New Issue