fmt, purged useless deps and removed mongoMS
Unit Tests with docker compose / unit-test (pull_request) Failing after 7m21s
Details
Unit Tests with docker compose / unit-test (pull_request) Failing after 7m21s
Details
This commit is contained in:
parent
49b159f9dc
commit
9cd61c101c
|
@ -4,12 +4,10 @@
|
|||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.11",
|
||||
"@types/mongodb-memory-server": "^2.3.0",
|
||||
"@types/supertest": "^6.0.1",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/express-list-endpoints": "^6.0.3",
|
||||
"@types/jsonwebtoken": "^9.0.5",
|
||||
"@types/mongoose": "^5.11.97",
|
||||
"bun-types": "latest",
|
||||
"jest": "^29.7.0",
|
||||
"mongodb-memory-server": "^9.1.3",
|
||||
|
@ -30,10 +28,5 @@
|
|||
"express-list-endpoints": "^6.0.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"mongoose": "^8.0.3"
|
||||
},
|
||||
"config": {
|
||||
"mongodbMemoryServer": {
|
||||
"debug": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,7 @@ class ImageController {
|
|||
} catch (error: any) {
|
||||
if (error instanceof mongo.MongoServerError && error.code === 11000) {
|
||||
// Should return 409 Conflict for existing urls
|
||||
res
|
||||
.status(409)
|
||||
.json({
|
||||
res.status(409).json({
|
||||
error: `the image with URL ${error.keyValue.url} already exists`,
|
||||
});
|
||||
} else if (error instanceof mongoose.Error.ValidationError) {
|
||||
|
|
|
@ -3,10 +3,6 @@ import { startApp } from "./app";
|
|||
|
||||
await startApp();
|
||||
|
||||
|
||||
try {
|
||||
await populateDatabase();
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
} catch {}
|
||||
|
|
|
@ -5,7 +5,8 @@ export interface Auth extends Document {
|
|||
secret: String;
|
||||
}
|
||||
|
||||
const AuthSchema = new mongoose.Schema({
|
||||
const AuthSchema = new mongoose.Schema(
|
||||
{
|
||||
app: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
@ -15,6 +16,8 @@ const AuthSchema = new mongoose.Schema({
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
}, { collection: "authorizations" });
|
||||
},
|
||||
{ collection: "authorizations" }
|
||||
);
|
||||
|
||||
export default mongoose.model("authorizations", AuthSchema);
|
||||
|
|
|
@ -6,12 +6,13 @@ export interface Image extends Document {
|
|||
tags?: String[];
|
||||
}
|
||||
|
||||
const ImageSchema = new mongoose.Schema({
|
||||
const ImageSchema = new mongoose.Schema(
|
||||
{
|
||||
url: {
|
||||
type: String,
|
||||
required: true,
|
||||
index: true,
|
||||
unique: true
|
||||
unique: true,
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
|
@ -24,6 +25,8 @@ const ImageSchema = new mongoose.Schema({
|
|||
tags: {
|
||||
type: [String],
|
||||
},
|
||||
}, { collection: "images" });
|
||||
},
|
||||
{ collection: "images" }
|
||||
);
|
||||
|
||||
export default mongoose.model<Image>("images", ImageSchema);
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
import { afterAll, afterEach, beforeAll, describe, expect, it, mock } from "bun:test";
|
||||
import {
|
||||
afterAll,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
mock,
|
||||
} from "bun:test";
|
||||
import request, { Response } from "supertest";
|
||||
import app, { startApp } from "../src/app";
|
||||
import imageService from "../src/services/ImageService";
|
||||
|
@ -10,8 +18,7 @@ const imageServiceOriginal = imageService;
|
|||
let token: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
if (!process.env.DEDICATED_MONGODB_SERVER)
|
||||
await memoryServer.start();
|
||||
//if (!process.env.DEDICATED_MONGODB_SERVER) await memoryServer.start();
|
||||
await startApp();
|
||||
await populateDatabase();
|
||||
|
||||
|
@ -21,11 +28,10 @@ beforeAll(async () => {
|
|||
token = tok.body.token;
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
if (!process.env.DEDICATED_MONGODB_SERVER)
|
||||
await memoryServer.stop();
|
||||
})
|
||||
|
||||
/* afterAll(async () => {
|
||||
if (!process.env.DEDICATED_MONGODB_SERVER) await memoryServer.stop();
|
||||
});
|
||||
*/
|
||||
afterEach(() => {
|
||||
mock.restore();
|
||||
mock.module("../src/services/ImageService", () => ({
|
||||
|
|
Loading…
Reference in New Issue