Merge pull request #12320 from Budibase/fix-test-flake-in-row-tests

Reduce the likelihood of collisions in table names by using a UUID instead of a random word.
This commit is contained in:
Sam Rose 2023-11-08 12:03:25 +00:00 committed by GitHub
commit a3f6d2f460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -32,6 +32,7 @@ import {
structures, structures,
} from "@budibase/backend-core/tests" } from "@budibase/backend-core/tests"
import _ from "lodash" import _ from "lodash"
import * as uuid from "uuid"
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)
@ -68,7 +69,7 @@ describe.each([
const generateTableConfig: () => SaveTableRequest = () => { const generateTableConfig: () => SaveTableRequest = () => {
return { return {
name: generator.word(), name: uuid.v4(),
type: "table", type: "table",
primary: ["id"], primary: ["id"],
primaryDisplay: "name", primaryDisplay: "name",
@ -481,7 +482,7 @@ describe.each([
}) })
const createViewResponse = await config.createView({ const createViewResponse = await config.createView({
name: generator.word(), name: uuid.v4(),
schema: { schema: {
Country: { Country: {
visible: true, visible: true,
@ -816,7 +817,8 @@ describe.each([
RelationshipType.ONE_TO_MANY, RelationshipType.ONE_TO_MANY,
["link"], ["link"],
{ {
name: generator.word(), // Making sure that the combined table name + column name is within postgres limits
name: uuid.v4().replace(/-/g, "").substring(0, 16),
type: "table", type: "table",
primary: ["id"], primary: ["id"],
primaryDisplay: "id", primaryDisplay: "id",
@ -949,7 +951,7 @@ describe.each([
describe("view 2.0", () => { describe("view 2.0", () => {
async function userTable(): Promise<Table> { async function userTable(): Promise<Table> {
return { return {
name: `users_${generator.word()}`, name: `users_${uuid.v4()}`,
sourceId: INTERNAL_TABLE_SOURCE_ID, sourceId: INTERNAL_TABLE_SOURCE_ID,
sourceType: TableSourceType.INTERNAL, sourceType: TableSourceType.INTERNAL,
type: "table", type: "table",
@ -1133,7 +1135,7 @@ describe.each([
const viewSchema = { age: { visible: true }, name: { visible: true } } const viewSchema = { age: { visible: true }, name: { visible: true } }
async function userTable(): Promise<Table> { async function userTable(): Promise<Table> {
return { return {
name: `users_${generator.word()}`, name: `users_${uuid.v4()}`,
sourceId: INTERNAL_TABLE_SOURCE_ID, sourceId: INTERNAL_TABLE_SOURCE_ID,
sourceType: TableSourceType.INTERNAL, sourceType: TableSourceType.INTERNAL,
type: "table", type: "table",
@ -1630,7 +1632,7 @@ describe.each([
}), }),
(tableId: string) => (tableId: string) =>
config.api.row.save(tableId, { config.api.row.save(tableId, {
name: generator.word(), name: uuid.v4(),
description: generator.paragraph(), description: generator.paragraph(),
tableId, tableId,
}), }),