Changed relative paths to absolute paths
Unit Tests with docker compose / unit-test (push) Successful in 22s Details
Build image / build (push) Failing after 22s Details

This commit is contained in:
Sugui 2024-04-17 19:23:39 +02:00 committed by Alie
parent b3e39e32b0
commit a2fdf862dd
11 changed files with 33 additions and 32 deletions

View File

@ -1,7 +1,7 @@
import compression from "compression";
import express from "express";
import listEndpoints from "express-list-endpoints";
import ImageController from "./controllers/ImageController";
import ImageController from "src/controllers/ImageController";
const app = express();

View File

@ -1,5 +1,5 @@
import { Request, Response } from "express";
import ImageService from "../services/ImageService";
import ImageService from "src/services/ImageService";
class ImageController {
async get(req: Request, res: Response) {

View File

@ -1,5 +1,5 @@
import { env } from "bun";
import app from "./app";
import app from "src/app";
const PORT = env.PORT;

View File

@ -1,5 +1,5 @@
import { env } from "bun";
import { BotApiResponse } from "../types/BotApiResponse";
import { BotApiResponse } from "src/types/BotApiResponse";
class BotApiService {
readonly BOT_API_URI = env.BOT_API_URI;

View File

@ -1,5 +1,5 @@
import GelbooruApiResponse from "../types/GelbooruApiResponse";
import GelbooruServiceResponse from "../types/GelbooruServiceResponse";
import GelbooruApiResponse from "src/types/GelbooruApiResponse";
import GelbooruServiceResponse from "src/types/GelbooruServiceResponse";
class GelbooruApiService {
async get(): Promise<GelbooruServiceResponse> {

View File

@ -1,7 +1,7 @@
import GelbooruServiceResponse from "../types/GelbooruServiceResponse";
import Image from "../types/Image";
import BotApiService from "./BotApiService";
import GelbooruApiService from "./GelbooruApiService";
import GelbooruServiceResponse from "src/types/GelbooruServiceResponse";
import Image from "src/types/Image";
import BotApiService from "src/services/BotApiService";
import GelbooruApiService from "src/services/GelbooruApiService";
class ImageService {
postsQueue: Image[] = [];

View File

@ -1,4 +1,4 @@
import BotImage from "./BotImage";
import BotImage from "src/types/BotImage";
export interface BotApiResponse {
images: BotImage[]

View File

@ -1,4 +1,4 @@
import GelbooruPost from "./GelbooruPost";
import GelbooruPost from "src/types/GelbooruPost";
export default interface GelbooruServiceResponse {
posts: GelbooruPost[];

View File

@ -1,18 +1,18 @@
import { afterEach, describe, expect, it, mock, jest } from "bun:test";
import Image from "../../src/types/Image";
import ImageService from "../../src/services/ImageService";
import GelbooruApiResponse from "../../src/types/GelbooruServiceResponse";
import { BotApiResponse } from "../../src/types/BotApiResponse";
import Image from "src/types/Image";
import ImageService from "src/services/ImageService";
import GelbooruApiResponse from "src/types/GelbooruServiceResponse";
import { BotApiResponse } from "src/types/BotApiResponse";
import fs from "node:fs";
import ImageController from "../../src/controllers/ImageController";
import app from "../../src/app";
import ImageController from "src/controllers/ImageController";
import app from "src/app";
import request from "supertest";
const imageServiceOriginal = ImageService;
afterEach(() => {
mock.restore();
mock.module("../../src/services/ImageService", () => ({
mock.module("src/services/ImageService", () => ({
default: imageServiceOriginal,
}));
})
@ -26,7 +26,7 @@ describe("endpoint returns the correct status codes", () => {
});
it("should return 500 if any error happens", async () => {
mock.module("../../src/services/ImageService", () => {
mock.module("src/services/ImageService", () => {
return {
default: {
get: () => {

View File

@ -1,10 +1,10 @@
import { afterEach, describe, expect, it, mock, spyOn } from "bun:test";
import Image from "../../src/types/Image";
import ImageService from "../../src/services/ImageService";
import GelbooruApiResponse from "../../src/types/GelbooruServiceResponse";
import { BotApiResponse } from "../../src/types/BotApiResponse";
import GelbooruApiService from "../../src/services/GelbooruApiService";
import BotApiService from "../../src/services/BotApiService";
import Image from "src/types/Image";
import ImageService from "src/services/ImageService";
import GelbooruApiResponse from "src/types/GelbooruServiceResponse";
import { BotApiResponse } from "src/types/BotApiResponse";
import GelbooruApiService from "src/services/GelbooruApiService";
import BotApiService from "src/services/BotApiService";
import fs from "node:fs";
const imageServiceOriginal = ImageService;
@ -13,13 +13,13 @@ const botApiServiceOriginal = BotApiService;
afterEach(() => {
mock.restore();
mock.module("../../src/services/ImageService", () => ({
mock.module("src/services/ImageService", () => ({
default: imageServiceOriginal,
}));
mock.module("../../src/services/GelbooruApiService", () => ({
mock.module("src/services/GelbooruApiService", () => ({
default: gelbooruApiServiceOriginal,
}));
mock.module("../../src/services/BotApiService", () => ({
mock.module("src/services/BotApiService", () => ({
default: botApiServiceOriginal
}));
})
@ -29,7 +29,7 @@ describe("endpoint gets a non repeated image", () => {
const REPEATED_URL = "https://fastly.picsum.photos/id/1/10/20.jpg?hmac=gY6PvUXFacKfYpBpTTVcNLxumpyMmoCamM-J5DOPwNc";
const UNIQUE_URL = "https://fastly.picsum.photos/id/2/10/20.jpg?hmac=zy6lz21CuRIstr9ETx9h5AuoH50s_L2uIEct3dROpY8";
mock.module("../../src/services/GelbooruApiService", () => {
mock.module("src/services/GelbooruApiService", () => {
let alreadyCalled = false;
return {
default: {
@ -45,7 +45,7 @@ describe("endpoint gets a non repeated image", () => {
}
});
mock.module("../../src/services/BotApiService", () => ({
mock.module("src/services/BotApiService", () => ({
default: {
getAll: (): BotApiResponse => ({
images: [

View File

@ -17,6 +17,7 @@
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
],
"baseUrl": "./",
}
}