From 45a4935190a5bdf7fe9a88702745e45a75afeac1 Mon Sep 17 00:00:00 2001 From: grey Date: Sun, 9 Jul 2023 23:37:48 +0200 Subject: [PATCH] added tool for load-testing many items --- .gitignore | 1 + tools/generate.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tools/generate.js diff --git a/.gitignore b/.gitignore index 6cde58e..65e80e1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules config.json dist docs +demoData.json \ No newline at end of file diff --git a/tools/generate.js b/tools/generate.js new file mode 100644 index 0000000..62ba028 --- /dev/null +++ b/tools/generate.js @@ -0,0 +1,35 @@ +/** +* This file can be used to load-test the application +*/ + +import { writeFileSync } from "fs"; + +// Temporary file to generate demo data for the inventory +const inventoryItems = []; + +// Function to add an item to the inventory using a simple function +function addInventoryItem(name, amount, manufacturer, category, sku) { + const item = { + name: name, + amount: amount, + manufacturer: manufacturer, + category: category, + sku: sku + }; + + inventoryItems.push(item); +} + +// Loop to generate 2000 items +for (let i = 1; i <= 1024; i++) { + const itemName = `Item ${i}`; + const itemAmount = Math.floor(Math.random() * 100) + 1; + const itemManufacturer = `Manufacturer ${i}`; + const itemCategory = `Category ${i}`; + const itemSKU = `SKU-${i}`; + + addInventoryItem(itemName, itemAmount, itemManufacturer, itemCategory, itemSKU); +} + +// Save the generated data to a file +writeFileSync('demoData.json', JSON.stringify(inventoryItems))