diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index 5c2c4ef684..0650305ac1 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -154,7 +154,7 @@ export async function verify( } } -export async function tables( +export async function fetchTables( ctx: UserCtx ) { const datasourceId = ctx.params.datasourceId diff --git a/packages/server/src/api/routes/datasource.ts b/packages/server/src/api/routes/datasource.ts index 89bc12c543..e740510d7f 100644 --- a/packages/server/src/api/routes/datasource.ts +++ b/packages/server/src/api/routes/datasource.ts @@ -23,7 +23,7 @@ router .get( "/api/datasources/:datasourceId/tables", authorized(permissions.BUILDER), - datasourceController.tables + datasourceController.fetchTables ) .get( "/api/datasources/:datasourceId", diff --git a/packages/server/src/integration-test/postgres.spec.ts b/packages/server/src/integration-test/postgres.spec.ts index 79f6db5cd1..c34f2a9bff 100644 --- a/packages/server/src/integration-test/postgres.spec.ts +++ b/packages/server/src/integration-test/postgres.spec.ts @@ -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,