Added fake data for testing and dev environment
Unit Tests with docker compose / unit-test (pull_request) Successful in 6m53s Details

This commit is contained in:
Sugui 2024-01-06 13:25:24 +01:00
parent 87f4719fd1
commit 1e18234437
2 changed files with 15 additions and 6 deletions

View File

@ -3,6 +3,7 @@
"module": "index.ts",
"type": "module",
"devDependencies": {
"@faker-js/faker": "^8.3.1",
"@types/express": "^4.17.21",
"@types/express-list-endpoints": "^6.0.3",
"@types/jest": "^29.5.11",

View File

@ -1,12 +1,20 @@
import authModel from "../src/models/AuthModel";
import imageModel from "../src/models/ImageModel";
import imageModel, { Image } from "../src/models/ImageModel";
import { faker } from '@faker-js/faker';
export default async function () {
await imageModel.create({
url: "https://example.com",
status: "consumed",
tags: ["2girls", "sleeping"],
});
const images = faker.helpers.multiple(() => ({
url: faker.helpers.unique(faker.internet.url),
status: faker.helpers.arrayElement(["available", "unavailable", "consumed"]),
tags: faker.helpers.arrayElements([
"2girls", "sleeping", "touhou",
"pokemon", "closed_eyes", "yume_nikki",
"waifu", "computer", "party", "yuru_camp"
], { min: 0, max: 5 }),
}), {count: {min: 5, max:50}});
// Wait until all images are inserted
await Promise.allSettled(images.map(image => imageModel.create(image)));
await authModel.create({
app: "tester",