1
0
Fork 0
mirror of synced 2024-09-08 21:51:58 +12:00

Datasource test api

This commit is contained in:
Adria Navarro 2023-09-04 18:53:32 +02:00
parent cb6977a18b
commit 8931309669
3 changed files with 34 additions and 1 deletions

View file

@ -684,7 +684,11 @@ class TestConfiguration {
datasource: Datasource
}): Promise<Datasource> {
config = config || basicDatasource()
const response = await this._req(config, null, controllers.datasource.save)
const response = await this._req(
{ ...config },
null,
controllers.datasource.save
)
this.datasource = response.datasource
return this.datasource!
}

View file

@ -0,0 +1,26 @@
import { CreateDatasourceRequest, Datasource } from "@budibase/types"
import TestConfiguration from "../TestConfiguration"
import { TestAPI } from "./base"
export class DatasourceAPI extends TestAPI {
constructor(config: TestConfiguration) {
super(config)
}
create = async (
config: Datasource,
{ expectStatus } = { expectStatus: 200 }
): Promise<Datasource> => {
const body: CreateDatasourceRequest = {
datasource: config,
tablesFilter: [],
}
const result = await this.request
.post(`/api/datasources`)
.send(body)
.set(this.config.defaultHeaders())
.expect("Content-Type", /json/)
.expect(expectStatus)
return result.body.datasource as Datasource
}
}

View file

@ -3,17 +3,20 @@ import { PermissionAPI } from "./permission"
import { RowAPI } from "./row"
import { TableAPI } from "./table"
import { ViewV2API } from "./viewV2"
import { DatasourceAPI } from "./datasource"
export default class API {
table: TableAPI
viewV2: ViewV2API
row: RowAPI
permission: PermissionAPI
datasource: DatasourceAPI
constructor(config: TestConfiguration) {
this.table = new TableAPI(config)
this.viewV2 = new ViewV2API(config)
this.row = new RowAPI(config)
this.permission = new PermissionAPI(config)
this.datasource = new DatasourceAPI(config)
}
}