Datasource test api
This commit is contained in:
parent
cb6977a18b
commit
8931309669
|
@ -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!
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue