More typings

This commit is contained in:
Adria Navarro 2023-01-18 10:45:42 +00:00
parent cc930097a8
commit 1d66110d01
2 changed files with 17 additions and 16 deletions

View File

@ -39,7 +39,7 @@ import newid from "../../db/newid"
import { generateUserMetadataID } from "../../db/utils"
import { startup } from "../../startup"
import supertest from "supertest"
import { Table } from "@budibase/types"
import { Datasource, SourceName, Table } from "@budibase/types"
const GLOBAL_USER_ID = "us_uuid1"
const EMAIL = "babs@babs.com"
@ -554,9 +554,13 @@ class TestConfiguration {
// DATASOURCE
async createDatasource(config?: any) {
async createDatasource(config?: Datasource): Promise<Datasource> {
config = config || basicDatasource()
const response = await this._req(config, null, controllers.datasource.save)
const response = await this._req(
{ datasource: config },
null,
controllers.datasource.save
)
this.datasource = response.datasource
return this.datasource
}
@ -573,18 +577,16 @@ class TestConfiguration {
async restDatasource(cfg?: any) {
return this.createDatasource({
datasource: {
...basicDatasource().datasource,
source: "REST",
...basicDatasource(),
source: SourceName.REST,
config: cfg || {},
},
})
}
async dynamicVariableDatasource() {
let datasource = await this.restDatasource()
const basedOnQuery = await this.createQuery({
...basicQuery(datasource._id),
...basicQuery(datasource._id!),
fields: {
path: "www.google.com",
},

View File

@ -3,6 +3,7 @@ import { createHomeScreen } from "../../constants/screens"
import { EMPTY_LAYOUT } from "../../constants/layouts"
import { cloneDeep } from "lodash/fp"
import { TRIGGER_DEFINITIONS, ACTION_DEFINITIONS } from "../../automations"
import { Datasource, SourceName } from "@budibase/types"
const { v4: uuidv4 } = require("uuid")
export const TENANT_ID = "default"
@ -144,14 +145,12 @@ export function basicRole() {
}
}
export function basicDatasource() {
export function basicDatasource(): Datasource {
return {
datasource: {
type: "datasource",
name: "Test",
source: "POSTGRES",
source: SourceName.POSTGRES,
config: {},
},
}
}