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

View File

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