Skip to content

Commit

Permalink
chore: seed the default user (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
derevnjuk authored Mar 30, 2023
1 parent e4fc391 commit c24fe22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/migrations/Migration20220527191127.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export class Migration20220527191127 extends Migration {
await this.addSql(
'create table "user" ("id" serial primary key, "first_name" varchar(255) not null, "last_name" varchar(255) not null, "is_active" boolean not null default true);'
);
await this.addSql(
`insert into "user" ("first_name", "last_name") values ('Matti', 'Karttunen');`
);
}

public async down(): Promise<void> {
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/users.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { MikroOrmModule } from '@mikro-orm/nestjs';

describe('/users', () => {
const user = {
id: 1,
firstName: 'FirstName #1',
lastName: 'LastName #1',
id: 2,
firstName: 'Karl',
lastName: 'Jablonski',
isActive: true
};

Expand Down Expand Up @@ -53,15 +53,15 @@ describe('/users', () => {
describe('GET /:id', () => {
it('should return an user by ID', async () => {
const res = await request(app.getHttpServer())
.get('/users/1')
.get('/users/2')
.expect(200);

expect(res).toMatchObject({ body: user });
});

it('should return an user if boolean-based blind is used', async () => {
const res = await request(app.getHttpServer())
.get('/users/1 AND 1858=1858')
.get('/users/2 AND 1858=1858')
.expect(200);

expect(res).toMatchObject({ body: user });
Expand Down

0 comments on commit c24fe22

Please sign in to comment.