Adding test for postgres verify.

This commit is contained in:
Michael Drury 2023-05-19 12:19:55 +01:00
parent 2223027d28
commit d85bcbc7e5
3 changed files with 22 additions and 5 deletions

View File

@ -154,7 +154,7 @@ export async function verify(
}
}
export async function tables(
export async function fetchTables(
ctx: UserCtx<void, FetchTablesDatasourceResponse>
) {
const datasourceId = ctx.params.datasourceId

View File

@ -23,7 +23,7 @@ router
.get(
"/api/datasources/:datasourceId/tables",
authorized(permissions.BUILDER),
datasourceController.tables
datasourceController.fetchTables
)
.get(
"/api/datasources/:datasourceId",

View File

@ -52,8 +52,8 @@ describe("row api - postgres", () => {
makeRequest = generateMakeRequest(apiKey, true)
})
beforeEach(async () => {
postgresDatasource = await config.createDatasource({
function pgDatasourceConfig() {
return {
datasource: {
type: "datasource",
source: SourceName.POSTGRES,
@ -70,7 +70,11 @@ describe("row api - postgres", () => {
ca: false,
},
},
})
}
}
beforeEach(async () => {
postgresDatasource = await config.createDatasource(pgDatasourceConfig())
async function createAuxTable(prefix: string) {
return await config.createTable({
@ -439,6 +443,19 @@ 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,