From aa8aa2b3110802a0bd98cd5d8a6cd3c05e101596 Mon Sep 17 00:00:00 2001 From: adrinr Date: Wed, 1 Feb 2023 17:11:50 +0000 Subject: [PATCH] Replace faker for chance --- packages/backend-core/package.json | 3 +-- .../src/cache/tests/writethrough.spec.js | 8 ++++---- packages/backend-core/src/db/tests/index.spec.js | 7 ++++--- packages/backend-core/yarn.lock | 10 +++++----- packages/server/package.json | 3 +-- .../server/src/tests/utilities/TestConfiguration.ts | 13 ++++++------- packages/server/yarn.lock | 5 ----- 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 86a0a975de..fa9cccfdd1 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -57,7 +57,6 @@ "zlib": "1.0.5" }, "devDependencies": { - "@faker-js/faker": "^7.6.0", "@swc/core": "^1.3.25", "@swc/jest": "^0.2.24", "@trendyol/jest-testcontainers": "^2.1.1", @@ -89,4 +88,4 @@ "typescript": "4.7.3" }, "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc" -} +} \ No newline at end of file diff --git a/packages/backend-core/src/cache/tests/writethrough.spec.js b/packages/backend-core/src/cache/tests/writethrough.spec.js index 67728c0f51..058d4321d4 100644 --- a/packages/backend-core/src/cache/tests/writethrough.spec.js +++ b/packages/backend-core/src/cache/tests/writethrough.spec.js @@ -1,4 +1,4 @@ -require("../../../tests") +const{generator}=require("../../../tests") const { Writethrough } = require("../writethrough") const { getDB } = require("../../db") const tk = require("timekeeper") @@ -6,12 +6,12 @@ const tk = require("timekeeper") const START_DATE = Date.now() tk.freeze(START_DATE) -const { faker } = require( "@faker-js/faker") +const { newid } = require("../../newid") const DELAY = 5000 -const db = getDB(faker.random.alpha(10)) -const db2 = getDB(faker.random.alpha(10)) +const db = getDB(`db_${newid()}`) +const db2 = getDB(`db_${newid()}`) const writethrough = new Writethrough(db, DELAY), writethrough2 = new Writethrough(db2, DELAY) describe("writethrough", () => { diff --git a/packages/backend-core/src/db/tests/index.spec.js b/packages/backend-core/src/db/tests/index.spec.js index e10df7ef07..56041ea732 100644 --- a/packages/backend-core/src/db/tests/index.spec.js +++ b/packages/backend-core/src/db/tests/index.spec.js @@ -1,18 +1,19 @@ require("../../../tests") +const { newid } = require("../../newid") const { getDB } = require("../db") -const { faker } = require( "@faker-js/faker") describe("db", () => { describe("getDB", () => { it("returns a db", async () => { - const dbName = faker.random.alpha(10) + + const dbName = `db_${newid()}` const db = getDB(dbName) expect(db).toBeDefined() expect(db.name).toBe(dbName) }) it("uses the custom put function", async () => { - const db = getDB(faker.random.alpha(10)) + const db = getDB(`db_${newid()}`) let doc = { _id: "test" } await db.put(doc) doc = await db.get(doc._id) diff --git a/packages/backend-core/yarn.lock b/packages/backend-core/yarn.lock index 77550c9bae..4e3b774337 100644 --- a/packages/backend-core/yarn.lock +++ b/packages/backend-core/yarn.lock @@ -487,6 +487,11 @@ qs "^6.11.0" tough-cookie "^4.1.2" +"@budibase/types@2.2.12-alpha.59": + version "2.2.12-alpha.59" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12-alpha.59.tgz#41635c1e405acfa6162b5ca0f79f0c73f16bc764" + integrity sha512-cEcM0nnTEOEan9UYVspwcdgYgIbtY2zQTe1uDdwys+NFplMrbiwGyQbsafOx2IA0jCxmyqqYGmUAC0eF1napKQ== + "@cspotcode/source-map-support@^0.8.0": version "0.8.1" resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" @@ -494,11 +499,6 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@faker-js/faker@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-7.6.0.tgz#9ea331766084288634a9247fcd8b84f16ff4ba07" - integrity sha512-XK6BTq1NDMo9Xqw/YkYyGjSsg44fbNwYRx7QK2CuoQgyy+f1rrTDHoExVM5PsyXCtfl2vs2vVJ0MN0yN6LppRw== - "@hapi/hoek@^9.0.0": version "9.3.0" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" diff --git a/packages/server/package.json b/packages/server/package.json index 941eccfb2b..6017be72fe 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -122,7 +122,6 @@ "@babel/core": "7.17.4", "@babel/preset-env": "7.16.11", "@budibase/standard-components": "^0.9.139", - "@faker-js/faker": "^7.6.0", "@jest/test-sequencer": "24.9.0", "@swc/core": "^1.3.25", "@swc/jest": "^0.2.24", @@ -173,4 +172,4 @@ "oracledb": "5.3.0" }, "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc" -} +} \ No newline at end of file diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 688b3cd698..40a263fb27 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -1,5 +1,4 @@ -import { faker } from "@faker-js/faker" -import { mocks } from "@budibase/backend-core/tests" +import { generator, mocks } from "@budibase/backend-core/tests" // init the licensing mock import * as pro from "@budibase/pro" @@ -89,11 +88,11 @@ class TestConfiguration { populateDefaultUserValues(): DefaultUserValues { return { - globalUserId: `us_${faker.datatype.uuid()}`, - email: faker.internet.email(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), - csrfToken: faker.datatype.uuid(), + globalUserId: `us_${newid()}`, + email: generator.email(), + firstName: generator.first(), + lastName: generator.last(), + csrfToken: generator.hash(), } } diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 8ffb9586d9..18017a2ac1 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1528,11 +1528,6 @@ pump "^3.0.0" secure-json-parse "^2.1.0" -"@faker-js/faker@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-7.6.0.tgz#9ea331766084288634a9247fcd8b84f16ff4ba07" - integrity sha512-XK6BTq1NDMo9Xqw/YkYyGjSsg44fbNwYRx7QK2CuoQgyy+f1rrTDHoExVM5PsyXCtfl2vs2vVJ0MN0yN6LppRw== - "@google-cloud/firestore@5.0.2": version "5.0.2" resolved "https://registry.yarnpkg.com/@google-cloud/firestore/-/firestore-5.0.2.tgz#36923fde45987f928a220d347f341c5602f9e340"