Fixing tests
All checks were successful
Anatid Blog CI Workflow / test (./backend) (push) Successful in 28s
Anatid Blog CI Workflow / test (./frontend) (push) Successful in 29s
Anatid Blog CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/anatid-blog-backend, ./backend) (push) Successful in 51s
Anatid Blog CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/anatid-blog-frontend, ./frontend) (push) Successful in 43s
Anatid Blog CI Workflow / deploy (push) Successful in 23s
All checks were successful
Anatid Blog CI Workflow / test (./backend) (push) Successful in 28s
Anatid Blog CI Workflow / test (./frontend) (push) Successful in 29s
Anatid Blog CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/anatid-blog-backend, ./backend) (push) Successful in 51s
Anatid Blog CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/anatid-blog-frontend, ./frontend) (push) Successful in 43s
Anatid Blog CI Workflow / deploy (push) Successful in 23s
This commit is contained in:
parent
6509965ddb
commit
6b414d9b71
@ -1,10 +1,9 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
import { PostsModule } from './posts/posts.module';
|
import { PostModule } from './post/post.module';
|
||||||
import { DatabaseModule } from './database/database.module';
|
import { DatabaseModule } from './database/database.module';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { PostModule } from './post/post.module';
|
|
||||||
import configuration from './config/configuration';
|
import configuration from './config/configuration';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
@ -13,7 +12,6 @@ import configuration from './config/configuration';
|
|||||||
load: [configuration]
|
load: [configuration]
|
||||||
}),
|
}),
|
||||||
DatabaseModule,
|
DatabaseModule,
|
||||||
PostsModule,
|
|
||||||
PostModule
|
PostModule
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
|
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
|
||||||
import { Post } from './post.entity';
|
import { Post } from '../post/post.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Comment {
|
export class Comment {
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { PostController } from './post.controller';
|
import { PostController } from './post.controller';
|
||||||
|
import { PostService } from './post.service';
|
||||||
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
|
import { Post } from './post.entity';
|
||||||
|
import { Comment } from '../comment/comment.entity';
|
||||||
|
|
||||||
|
const mockPost = new Post();
|
||||||
|
const mockComment = new Comment();
|
||||||
|
|
||||||
describe('PostController', () => {
|
describe('PostController', () => {
|
||||||
let controller: PostController;
|
let controller: PostController;
|
||||||
@ -7,6 +14,23 @@ describe('PostController', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [PostController],
|
controllers: [PostController],
|
||||||
|
providers: [
|
||||||
|
PostService,
|
||||||
|
{
|
||||||
|
provide: getRepositoryToken(Post),
|
||||||
|
useValue: {
|
||||||
|
save: jest.fn().mockResolvedValue(mockPost),
|
||||||
|
find: jest.fn().mockResolvedValue([mockPost]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: getRepositoryToken(Comment),
|
||||||
|
useValue: {
|
||||||
|
save: jest.fn().mockResolvedValue(mockComment),
|
||||||
|
find: jest.fn().mockResolvedValue([mockComment]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<PostController>(PostController);
|
controller = module.get<PostController>(PostController);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Post } from './post';
|
import { Post } from './post.entity';
|
||||||
|
|
||||||
describe('Post', () => {
|
describe('Post', () => {
|
||||||
it('should be defined', () => {
|
it('should be defined', () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from ‘typeorm’;
|
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
|
||||||
import { Comment } from ‘./comment.entity’;
|
import { Comment } from '../comment/comment.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Post {
|
export class Post {
|
||||||
|
@ -1,12 +1,36 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { PostService } from './post.service';
|
import { PostService } from './post.service';
|
||||||
|
import { PostController } from './post.controller';
|
||||||
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
|
import { Post } from './post.entity';
|
||||||
|
import { Comment } from '../comment/comment.entity';
|
||||||
|
|
||||||
|
const mockPost = new Post();
|
||||||
|
const mockComment = new Comment();
|
||||||
|
|
||||||
describe('PostService', () => {
|
describe('PostService', () => {
|
||||||
let service: PostService;
|
let service: PostService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [PostService],
|
controllers: [PostController],
|
||||||
|
providers: [
|
||||||
|
PostService,
|
||||||
|
{
|
||||||
|
provide: getRepositoryToken(Post),
|
||||||
|
useValue: {
|
||||||
|
save: jest.fn().mockResolvedValue(mockPost),
|
||||||
|
find: jest.fn().mockResolvedValue([mockPost]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: getRepositoryToken(Comment),
|
||||||
|
useValue: {
|
||||||
|
save: jest.fn().mockResolvedValue(mockComment),
|
||||||
|
find: jest.fn().mockResolvedValue([mockComment]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<PostService>(PostService);
|
service = module.get<PostService>(PostService);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user