Skip to content

Commit

Permalink
integration(@nestjs) add typeorm integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed May 25, 2018
1 parent 17a609c commit 7b5b054
Show file tree
Hide file tree
Showing 20 changed files with 2,263 additions and 13 deletions.
9 changes: 9 additions & 0 deletions integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ services:
ports:
- "1883:1883"
- "9001:9001"
restart: always
mysql:
image: mysql:5.7.22
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
ports:
- "3306:3306"
restart: always
8 changes: 4 additions & 4 deletions integration/microservices/e2e/sum-grpc.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as express from 'express';
import * as request from 'supertest';
import { Test } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import { join } from 'path';
import * as request from 'supertest';
import { GrpcController } from '../src/grpc/grpc.controller';

describe('GRPC transport', () => {
Expand All @@ -21,7 +21,7 @@ describe('GRPC transport', () => {
transport: Transport.GRPC,
options: {
package: 'math',
protoPath: join(__dirname, './../src/grpc/math.proto')
protoPath: join(__dirname, './../src/grpc/math.proto'),
},
});
await app.startAllMicroservicesAsync();
Expand Down
21 changes: 21 additions & 0 deletions integration/typeorm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# dependencies
/node_modules

# IDE
/.idea
/.awcache
/.vscode

# misc
npm-debug.log

# example
/quick-start

# tests
/test
/coverage
/.nyc_output

# dist
/dist
29 changes: 29 additions & 0 deletions integration/typeorm/e2e/typeorm.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { ApplicationModule } from './../src/app.module';

describe('TypeOrm', () => {
let server;
let app: INestApplication;

beforeEach(async () => {
const module = await Test.createTestingModule({
imports: [ApplicationModule],
}).compile();

app = module.createNestApplication();
server = app.getHttpServer();
await app.init();
});

it(`should return created entity`, () => {
return request(server)
.post('/photo')
.expect(201, { name: 'Nest', description: 'Is great!', views: 6000 });
});

afterEach(async () => {
await app.close();
});
});
10 changes: 10 additions & 0 deletions integration/typeorm/ormconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "mysql",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "root",
"database": "test",
"entities": ["src/**/**.entity{.ts,.js}"],
"synchronize": true
}
Loading

0 comments on commit 7b5b054

Please sign in to comment.