Migrate viewV2.spec.ts to new datasource providers.
This commit is contained in:
parent
2304aeaa71
commit
b84bbd6003
|
@ -19,8 +19,7 @@ import {
|
||||||
ViewV2,
|
ViewV2,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { generator, mocks } from "@budibase/backend-core/tests"
|
import { generator, mocks } from "@budibase/backend-core/tests"
|
||||||
import * as uuid from "uuid"
|
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
|
||||||
import { databaseTestProviders } from "../../../integrations/tests/utils"
|
|
||||||
import merge from "lodash/merge"
|
import merge from "lodash/merge"
|
||||||
import { quotas } from "@budibase/pro"
|
import { quotas } from "@budibase/pro"
|
||||||
import { roles } from "@budibase/backend-core"
|
import { roles } from "@budibase/backend-core"
|
||||||
|
@ -30,10 +29,10 @@ jest.unmock("pg")
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
["internal", undefined],
|
["internal", undefined],
|
||||||
["postgres", databaseTestProviders.postgres],
|
[DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
||||||
["mysql", databaseTestProviders.mysql],
|
[DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
||||||
["mssql", databaseTestProviders.mssql],
|
[DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
||||||
["mariadb", databaseTestProviders.mariadb],
|
[DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
||||||
])("/v2/views (%s)", (_, dsProvider) => {
|
])("/v2/views (%s)", (_, dsProvider) => {
|
||||||
const config = setup.getConfig()
|
const config = setup.getConfig()
|
||||||
const isInternal = !dsProvider
|
const isInternal = !dsProvider
|
||||||
|
@ -42,10 +41,10 @@ describe.each([
|
||||||
let datasource: Datasource
|
let datasource: Datasource
|
||||||
|
|
||||||
function saveTableRequest(
|
function saveTableRequest(
|
||||||
...overrides: Partial<SaveTableRequest>[]
|
...overrides: Partial<Omit<SaveTableRequest, "name">>[]
|
||||||
): SaveTableRequest {
|
): SaveTableRequest {
|
||||||
const req: SaveTableRequest = {
|
const req: SaveTableRequest = {
|
||||||
name: uuid.v4().substring(0, 16),
|
name: generator.guid().replaceAll("-", "").substring(0, 16),
|
||||||
type: "table",
|
type: "table",
|
||||||
sourceType: datasource
|
sourceType: datasource
|
||||||
? TableSourceType.EXTERNAL
|
? TableSourceType.EXTERNAL
|
||||||
|
@ -90,16 +89,13 @@ describe.each([
|
||||||
|
|
||||||
if (dsProvider) {
|
if (dsProvider) {
|
||||||
datasource = await config.createDatasource({
|
datasource = await config.createDatasource({
|
||||||
datasource: await dsProvider.datasource(),
|
datasource: await dsProvider,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
table = await config.api.table.save(priceTable())
|
table = await config.api.table.save(priceTable())
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
if (dsProvider) {
|
|
||||||
await dsProvider.stop()
|
|
||||||
}
|
|
||||||
setup.afterAll()
|
setup.afterAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -507,7 +503,6 @@ describe.each([
|
||||||
it("views have extra data trimmed", async () => {
|
it("views have extra data trimmed", async () => {
|
||||||
const table = await config.api.table.save(
|
const table = await config.api.table.save(
|
||||||
saveTableRequest({
|
saveTableRequest({
|
||||||
name: "orders",
|
|
||||||
schema: {
|
schema: {
|
||||||
Country: {
|
Country: {
|
||||||
type: FieldType.STRING,
|
type: FieldType.STRING,
|
||||||
|
@ -523,7 +518,7 @@ describe.each([
|
||||||
|
|
||||||
const view = await config.api.viewV2.create({
|
const view = await config.api.viewV2.create({
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
name: uuid.v4(),
|
name: generator.guid(),
|
||||||
schema: {
|
schema: {
|
||||||
Country: {
|
Country: {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
@ -853,7 +848,6 @@ describe.each([
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
table = await config.api.table.save(
|
table = await config.api.table.save(
|
||||||
saveTableRequest({
|
saveTableRequest({
|
||||||
name: `users_${uuid.v4()}`,
|
|
||||||
type: "table",
|
type: "table",
|
||||||
schema: {
|
schema: {
|
||||||
name: {
|
name: {
|
||||||
|
|
|
@ -46,11 +46,3 @@ export async function getDatasources(
|
||||||
): Promise<Datasource[]> {
|
): Promise<Datasource[]> {
|
||||||
return Promise.all(sourceNames.map(sourceName => providers[sourceName]()))
|
return Promise.all(sourceNames.map(sourceName => providers[sourceName]()))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const databaseTestProviders = {
|
|
||||||
postgres,
|
|
||||||
mongodb,
|
|
||||||
mysql,
|
|
||||||
mssql,
|
|
||||||
mariadb,
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue