Run row api for pg
This commit is contained in:
parent
14303c9eb0
commit
f476c84bc2
|
@ -4,10 +4,12 @@ import * as setup from "./utilities"
|
||||||
import { context, tenancy } from "@budibase/backend-core"
|
import { context, tenancy } from "@budibase/backend-core"
|
||||||
import { quotas } from "@budibase/pro"
|
import { quotas } from "@budibase/pro"
|
||||||
import {
|
import {
|
||||||
|
Datasource,
|
||||||
FieldType,
|
FieldType,
|
||||||
MonthlyQuotaName,
|
MonthlyQuotaName,
|
||||||
QuotaUsageType,
|
QuotaUsageType,
|
||||||
Row,
|
Row,
|
||||||
|
SaveTableRequest,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
SortType,
|
SortType,
|
||||||
StaticQuotaName,
|
StaticQuotaName,
|
||||||
|
@ -18,18 +20,22 @@ import {
|
||||||
generator,
|
generator,
|
||||||
structures,
|
structures,
|
||||||
} from "@budibase/backend-core/tests"
|
} from "@budibase/backend-core/tests"
|
||||||
import { basicDatasource } from "../../../tests/utilities/structures"
|
import { databaseTestProviders } from "../../../integrations/tests/utils"
|
||||||
|
|
||||||
const timestamp = new Date("2023-01-26T11:48:57.597Z").toISOString()
|
const timestamp = new Date("2023-01-26T11:48:57.597Z").toISOString()
|
||||||
tk.freeze(timestamp)
|
tk.freeze(timestamp)
|
||||||
|
|
||||||
const { basicRow } = setup.structures
|
const { basicRow } = setup.structures
|
||||||
|
|
||||||
describe("/rows", () => {
|
describe.each([
|
||||||
|
["internal", undefined],
|
||||||
|
["postgres", databaseTestProviders.postgres],
|
||||||
|
])("/rows (%s)", (_, dsProvider) => {
|
||||||
let request = setup.getRequest()
|
let request = setup.getRequest()
|
||||||
let config = setup.getConfig()
|
let config = setup.getConfig()
|
||||||
let table: Table
|
let table: Table
|
||||||
let row: Row
|
let row: Row
|
||||||
|
let datasource: Datasource | undefined
|
||||||
|
|
||||||
afterAll(setup.afterAll)
|
afterAll(setup.afterAll)
|
||||||
|
|
||||||
|
@ -38,13 +44,48 @@ describe("/rows", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await config.createDatasource({
|
let tableConfig: SaveTableRequest = {
|
||||||
datasource: {
|
name: "TestTable",
|
||||||
...basicDatasource().datasource,
|
type: "table",
|
||||||
plus: false,
|
primary: ["id"],
|
||||||
|
schema: {
|
||||||
|
id: {
|
||||||
|
type: FieldType.AUTO,
|
||||||
|
name: "id",
|
||||||
|
autocolumn: true,
|
||||||
|
constraints: {
|
||||||
|
presence: true,
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
table = await config.createTable()
|
name: {
|
||||||
|
type: FieldType.STRING,
|
||||||
|
name: "name",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: FieldType.STRING,
|
||||||
|
name: "description",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dsProvider) {
|
||||||
|
datasource = await config.api.datasource.create(
|
||||||
|
await dsProvider.getDsConfig()
|
||||||
|
)
|
||||||
|
|
||||||
|
tableConfig.sourceId = datasource._id
|
||||||
|
if (datasource.plus) {
|
||||||
|
tableConfig.type = "external"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table = await config.api.table.create(tableConfig)
|
||||||
row = basicRow(table._id!)
|
row = basicRow(table._id!)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue