Skip to content

Commit

Permalink
chore: fix backend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellmueller committed Dec 2, 2024
1 parent 329633d commit da82e4b
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 36 deletions.
1 change: 0 additions & 1 deletion .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ concurrency:
jobs:
tests:
name: Tests
if: ${{ ! github.event.pull_request.draft }}
runs-on: ubuntu-24.04
timeout-minutes: 5
services:
Expand Down
2 changes: 1 addition & 1 deletion backend/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import request from "supertest";
import { Test } from "@nestjs/testing";
import type { INestApplication } from "@nestjs/common";
import { INestApplication } from "@nestjs/common";
import { AppModule } from "../src/app.module";

describe("AppController (e2e)", () => {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TestingModule } from "@nestjs/testing";
import { TestingModule } from "@nestjs/testing";
import { Test } from "@nestjs/testing";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Get } from "@nestjs/common";
import type { AppService } from "./app.service";
import { AppService } from "./app.service";

@Controller()
export class AppController {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "dotenv/config";
import type { MiddlewareConsumer } from "@nestjs/common";
import { MiddlewareConsumer } from "@nestjs/common";
import { Logger, Module, RequestMethod } from "@nestjs/common";
import { HTTPLoggerMiddleware } from "./middleware/req.res.logger";
import { loggingMiddleware, PrismaModule } from "nestjs-prisma";
Expand Down
4 changes: 2 additions & 2 deletions backend/src/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NestExpressApplication } from "@nestjs/platform-express";
import { NestExpressApplication } from "@nestjs/platform-express";
import { bootstrap } from "./app";

vi.mock("prom-client", () => ({
Expand All @@ -11,7 +11,7 @@ vi.mock("express-prom-bundle", () => ({
}));

vi.mock("./prom", () => ({
metricsMiddleware: vi.fn().mockImplementation((req, res, next) => next()),
metricsMiddleware: vi.fn().mockImplementation((_req, _res, next) => next()),
}));

describe("main", () => {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NestFactory } from "@nestjs/core";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import { AppModule } from "./app.module";
import { customLogger } from "./common/logger.config";
import type { NestExpressApplication } from "@nestjs/platform-express";
import { NestExpressApplication } from "@nestjs/platform-express";
import helmet from "helmet";
import { VersioningType } from "@nestjs/common";
import { metricsMiddleware } from "./prom";
Expand Down
2 changes: 1 addition & 1 deletion backend/src/common/logger.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WinstonModule, utilities } from "nest-winston";
import * as winston from "winston";
import type { LoggerService } from "@nestjs/common";
import { LoggerService } from "@nestjs/common";

const globalLoggerFormat: winston.Logform.Format = winston.format.timestamp({
format: "YYYY-MM-DD hh:mm:ss.SSS",
Expand Down
7 changes: 2 additions & 5 deletions backend/src/health.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Controller, Get } from "@nestjs/common";
import type {
HealthCheckService,
PrismaHealthIndicator,
} from "@nestjs/terminus";
import { HealthCheckService, PrismaHealthIndicator } from "@nestjs/terminus";
import { HealthCheck } from "@nestjs/terminus";
import type { PrismaService } from "nestjs-prisma";
import { PrismaService } from "nestjs-prisma";

@Controller("health")
export class HealthController {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NestExpressApplication } from "@nestjs/platform-express";
import { NestExpressApplication } from "@nestjs/platform-express";
import { bootstrap } from "./app";
import { Logger } from "@nestjs/common";
const logger = new Logger("NestApplication");
Expand Down
4 changes: 2 additions & 2 deletions backend/src/metrics.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, Res } from "@nestjs/common";
import type { Response } from "express";
import { Response } from "express";
import { register } from "./prom";
import type { PrismaService } from "nestjs-prisma";
import { PrismaService } from "nestjs-prisma";
@Controller("metrics")
export class MetricsController {
constructor(private prisma: PrismaService) {}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/middleware/req.res.logger.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test } from "@nestjs/testing";
import { HTTPLoggerMiddleware } from "./req.res.logger";
import type { Request, Response } from "express";
import { Request, Response } from "express";
import { Logger } from "@nestjs/common";

describe("HTTPLoggerMiddleware", () => {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/middleware/req.res.logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Request, Response, NextFunction } from "express";
import type { NestMiddleware } from "@nestjs/common";
import { Request, Response, NextFunction } from "express";
import { NestMiddleware } from "@nestjs/common";
import { Injectable, Logger } from "@nestjs/common";

@Injectable()
Expand Down
10 changes: 5 additions & 5 deletions backend/src/users/users.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { TestingModule } from "@nestjs/testing";
import { TestingModule } from "@nestjs/testing";
import { Test } from "@nestjs/testing";
import { UsersController } from "./users.controller";
import { UsersService } from "./users.service";
import request from "supertest";
import type { INestApplication } from "@nestjs/common";
import { INestApplication } from "@nestjs/common";
import { HttpException } from "@nestjs/common";
import type { CreateUserDto } from "./dto/create-user.dto";
import type { UpdateUserDto } from "./dto/update-user.dto";
import type { UserDto } from "./dto/user.dto";
import { CreateUserDto } from "./dto/create-user.dto";
import { UpdateUserDto } from "./dto/update-user.dto";
import { UserDto } from "./dto/user.dto";
import { PrismaService } from "nestjs-prisma";

describe("UserController", () => {
Expand Down
8 changes: 4 additions & 4 deletions backend/src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
HttpException,
} from "@nestjs/common";
import { ApiTags } from "@nestjs/swagger";
import type { UsersService } from "./users.service";
import type { CreateUserDto } from "./dto/create-user.dto";
import type { UpdateUserDto } from "./dto/update-user.dto";
import type { UserDto } from "./dto/user.dto";
import { UsersService } from "./users.service";
import { CreateUserDto } from "./dto/create-user.dto";
import { UpdateUserDto } from "./dto/update-user.dto";
import { UserDto } from "./dto/user.dto";

@ApiTags("users")
@Controller({ path: "users", version: "1" })
Expand Down
2 changes: 1 addition & 1 deletion backend/src/users/users.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TestingModule } from "@nestjs/testing";
import { TestingModule } from "@nestjs/testing";
import { Test } from "@nestjs/testing";
import { UsersService } from "./users.service";
import { PrismaService } from "nestjs-prisma";
Expand Down
8 changes: 4 additions & 4 deletions backend/src/users/users.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from "@nestjs/common";
import type { PrismaService } from "nestjs-prisma";
import { PrismaService } from "nestjs-prisma";

import type { CreateUserDto } from "./dto/create-user.dto";
import type { UpdateUserDto } from "./dto/update-user.dto";
import type { UserDto } from "./dto/user.dto";
import { CreateUserDto } from "./dto/create-user.dto";
import { UpdateUserDto } from "./dto/update-user.dto";
import { UserDto } from "./dto/user.dto";
import { Prisma } from "@prisma/client";

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"lib": ["es2022"],
"types": ["vitest/globals", "node"]
},
"include": ["src/**/*.ts", "e2e/**/*.ts", "vitest.config.ts"]
"include": ["src/**/*.ts", "e2e/**/*.ts", "**/*.ts", "vitest.config.ts"]
}
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default [
"@typescript-eslint/explicit-function-return-type": "off",

"@typescript-eslint/consistent-type-imports": [
"error",
"off",
{
prefer: "type-imports",
},
Expand Down

0 comments on commit da82e4b

Please sign in to comment.