diff --git a/core/.yarn/cache/@types-chance-npm-1.1.6-3dfdc6e3e5-a1845ff0a7.zip b/core/.yarn/cache/@types-chance-npm-1.1.6-3dfdc6e3e5-a1845ff0a7.zip new file mode 100644 index 0000000..2b6c501 Binary files /dev/null and b/core/.yarn/cache/@types-chance-npm-1.1.6-3dfdc6e3e5-a1845ff0a7.zip differ diff --git a/core/.yarn/cache/chance-npm-1.1.11-9201191b7b-2e871fcc76.zip b/core/.yarn/cache/chance-npm-1.1.11-9201191b7b-2e871fcc76.zip new file mode 100644 index 0000000..fa93fc5 Binary files /dev/null and b/core/.yarn/cache/chance-npm-1.1.11-9201191b7b-2e871fcc76.zip differ diff --git a/core/libs/testing/src/random.ts b/core/libs/testing/src/random.ts new file mode 100644 index 0000000..c9672bd --- /dev/null +++ b/core/libs/testing/src/random.ts @@ -0,0 +1,32 @@ +// eslint-disable-next-line node/no-unpublished-import +import {Chance} from "chance" + +interface Resource extends ResourceIdentifier { + resourceAddress: string +} + +interface ResourceIdentifier { + resourceType: string + resourceName: string +} + +const randomGenerator = new Chance() + +export function generateTerraformResource( + partial?: Partial +): Resource { + const defaultValues: ResourceIdentifier = { + resourceType: randomGenerator.word(), + resourceName: randomGenerator.word() + } + + const resourceIdentifier = { + ...defaultValues, + ...partial + } + + return { + ...resourceIdentifier, + resourceAddress: `${resourceIdentifier.resourceType}.${resourceIdentifier.resourceName}` + } +} diff --git a/core/package.json b/core/package.json index ebca4ed..065c914 100644 --- a/core/package.json +++ b/core/package.json @@ -36,11 +36,13 @@ "@nestjs/cli": "10.2.1", "@nestjs/schematics": "10.0.3", "@nestjs/testing": "10.2.8", + "@types/chance": "1.1.6", "@types/inquirer": "9.0.7", "@types/jest": "29.5.8", "@types/node": "18.18.9", "@typescript-eslint/eslint-plugin": "6.10.0", "@typescript-eslint/parser": "6.10.0", + "chance": "1.1.11", "eslint": "8.53.0", "eslint-config-prettier": "8.10.0", "eslint-plugin-jest": "27.6.0", diff --git a/core/yarn.lock b/core/yarn.lock index dfbfa24..de4dbd9 100644 --- a/core/yarn.lock +++ b/core/yarn.lock @@ -1229,6 +1229,13 @@ __metadata: languageName: node linkType: hard +"@types/chance@npm:^1.1.6": + version: 1.1.6 + resolution: "@types/chance@npm:1.1.6" + checksum: a1845ff0a70989d581b8f7628aaef1807276c0ae22d0c038013ebcac4f4bd57e6a765319377994cc3cae2122838638fdb2afe5232ee6b987b3f7ea2cddecbead + languageName: node + linkType: hard + "@types/eslint-scope@npm:^3.7.3": version: 3.7.7 resolution: "@types/eslint-scope@npm:3.7.7" @@ -2224,6 +2231,13 @@ __metadata: languageName: node linkType: hard +"chance@npm:1.1.11": + version: 1.1.11 + resolution: "chance@npm:1.1.11" + checksum: 2e871fcc76584d274f860f0f25380b6ab547caf0d22d8b043a313be73d5c3db38941373241f83aeba049e7511f752f9746dc722a0f2b0182020d493c4e11da84 + languageName: node + linkType: hard + "char-regex@npm:^1.0.2": version: 1.0.2 resolution: "char-regex@npm:1.0.2" @@ -6224,12 +6238,14 @@ __metadata: "@nestjs/core": 10.2.8 "@nestjs/schematics": 10.0.3 "@nestjs/testing": 10.2.8 + "@types/chance": ^1.1.6 "@types/inquirer": 9.0.7 "@types/jest": 29.5.8 "@types/node": 18.18.9 "@typescript-eslint/eslint-plugin": 6.10.0 "@typescript-eslint/parser": 6.10.0 ajv: 8.12.0 + chance: 1.1.11 eslint: 8.53.0 eslint-config-prettier: 8.10.0 eslint-plugin-jest: 27.6.0