-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5838b81
commit 7df7c23
Showing
32 changed files
with
1,340 additions
and
195 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
import { Module, NotFoundException } from '@nestjs/common'; | ||
import { DB_PASSWORD, DB_USERNAME, DEL_DB_URL } from '@src/config'; | ||
import { CoreModule } from '@src/core'; | ||
import { Module } from '@nestjs/common'; | ||
// import { Module, NotFoundException } from '@nestjs/common'; | ||
// import { DB_PASSWORD, DB_USERNAME, DEL_DB_URL } from '@src/config'; | ||
// import { CoreModule } from '@src/core'; | ||
import { Logger } from '@src/core/logger'; | ||
import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs'; | ||
import { AuthenticationModule } from '@src/modules/authentication/authentication.module'; | ||
import { AuthorizationModule } from '@src/modules'; | ||
import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq'; | ||
import { Dictionary, IPrimaryKey } from '@mikro-orm/core'; | ||
// import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs'; | ||
// import { AuthenticationModule } from '@src/modules/authentication/authentication.module'; | ||
// import { AuthorizationModule } from '@src/modules'; | ||
// import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq'; | ||
// import { Dictionary, IPrimaryKey } from '@mikro-orm/core'; | ||
import { DeletionRequestService } from './services/deletion-request.service'; | ||
import { DeletionRequestRepo } from './repo/deletion-request.repo'; | ||
|
||
const defaultMikroOrmOptions: MikroOrmModuleSyncOptions = { | ||
findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => | ||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
new NotFoundException(`The requested ${entityName}: ${where} has not been found.`), | ||
}; | ||
// const defaultMikroOrmOptions: MikroOrmModuleSyncOptions = { | ||
// findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => | ||
// // eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
// new NotFoundException(`The requested ${entityName}: ${where} has not been found.`), | ||
// }; | ||
|
||
@Module({ | ||
imports: [ | ||
AuthorizationModule, | ||
AuthenticationModule, | ||
CoreModule, | ||
RabbitMQWrapperTestModule, | ||
MikroOrmModule.forRoot({ | ||
...defaultMikroOrmOptions, | ||
type: 'mongo', | ||
clientUrl: DEL_DB_URL, | ||
password: DB_PASSWORD, | ||
user: DB_USERNAME, | ||
entities: [], | ||
}), | ||
// ConfigModule.forRoot(createConfigModuleOptions(config)), | ||
], | ||
// imports: [ | ||
// AuthorizationModule, | ||
// AuthenticationModule, | ||
// CoreModule, | ||
// RabbitMQWrapperTestModule, | ||
// MikroOrmModule.forRoot({ | ||
// ...defaultMikroOrmOptions, | ||
// type: 'mongo', | ||
// clientUrl: DEL_DB_URL, | ||
// password: DB_PASSWORD, | ||
// user: DB_USERNAME, | ||
// entities: [], | ||
// }), | ||
// ConfigModule.forRoot(createConfigModuleOptions(config)), | ||
// ], | ||
providers: [Logger, DeletionRequestService, DeletionRequestRepo], | ||
}) | ||
export class DeletionModule {} |
64 changes: 64 additions & 0 deletions
64
apps/server/src/modules/deletion/domain/deletion-log.do.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { deletionLogFactory } from './testing/factory/deletion-log.factory'; | ||
import { DeletionLog } from './deletion-log.do'; | ||
import { DeletionOperationModel } from './types/deletion-operation-model.enum'; | ||
import { DeletionDomainModel } from './types/deletion-domain-model.enum'; | ||
|
||
describe(DeletionLog.name, () => { | ||
describe('constructor', () => { | ||
describe('When constructor is called', () => { | ||
it('should create a deletionRequest by passing required properties', () => { | ||
const domainObject: DeletionLog = deletionLogFactory.build(); | ||
|
||
expect(domainObject instanceof DeletionLog).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('when passed a valid id', () => { | ||
const setup = () => { | ||
const domainObject: DeletionLog = deletionLogFactory.buildWithId(); | ||
|
||
return { domainObject }; | ||
}; | ||
|
||
it('should set the id', () => { | ||
const { domainObject } = setup(); | ||
|
||
const deletionLogDomainObject: DeletionLog = new DeletionLog(domainObject); | ||
|
||
expect(deletionLogDomainObject.id).toEqual(domainObject.id); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('getters', () => { | ||
describe('When getters are used', () => { | ||
it('getters should return proper values', () => { | ||
const props = { | ||
id: new ObjectId().toHexString(), | ||
domain: DeletionDomainModel.USER, | ||
operation: DeletionOperationModel.DELETE, | ||
modifiedCounter: 0, | ||
deletedCounter: 1, | ||
deletionRequestId: new ObjectId().toHexString(), | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
|
||
const deletionLogDo = new DeletionLog(props); | ||
const gettersValues = { | ||
id: deletionLogDo.id, | ||
domain: deletionLogDo.domain, | ||
operation: deletionLogDo.operation, | ||
modifiedCounter: deletionLogDo.modifiedCounter, | ||
deletedCounter: deletionLogDo.deletedCounter, | ||
deletionRequestId: deletionLogDo.deletionRequestId, | ||
createdAt: deletionLogDo.createdAt, | ||
updatedAt: deletionLogDo.updatedAt, | ||
}; | ||
|
||
expect(gettersValues).toEqual(props); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
apps/server/src/modules/deletion/domain/deletion-request.do.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { DeletionRequest } from './deletion-request.do'; | ||
import { DeletionDomainModel } from './types/deletion-domain-model.enum'; | ||
import { deletionRequestFactory } from './testing/factory/deletion-request.factory'; | ||
import { DeletionStatusModel } from './types/deletion-status-model.enum'; | ||
|
||
describe(DeletionRequest.name, () => { | ||
describe('constructor', () => { | ||
describe('When constructor is called', () => { | ||
it('should create a deletionRequest by passing required properties', () => { | ||
const domainObject: DeletionRequest = deletionRequestFactory.build(); | ||
|
||
expect(domainObject instanceof DeletionRequest).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('when passed a valid id', () => { | ||
const setup = () => { | ||
const domainObject: DeletionRequest = deletionRequestFactory.buildWithId(); | ||
|
||
return { domainObject }; | ||
}; | ||
|
||
it('should set the id', () => { | ||
const { domainObject } = setup(); | ||
|
||
const deletionRequestDomainObject: DeletionRequest = new DeletionRequest(domainObject); | ||
|
||
expect(deletionRequestDomainObject.id).toEqual(domainObject.id); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('getters', () => { | ||
describe('When getters are used', () => { | ||
it('getters should return proper values', () => { | ||
const props = { | ||
id: new ObjectId().toHexString(), | ||
domain: DeletionDomainModel.USER, | ||
deleteAfter: new Date(), | ||
itemId: new ObjectId().toHexString(), | ||
status: DeletionStatusModel.REGISTERED, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
|
||
const deletionRequestDo = new DeletionRequest(props); | ||
const gettersValues = { | ||
id: deletionRequestDo.id, | ||
domain: deletionRequestDo.domain, | ||
deleteAfter: deletionRequestDo.deleteAfter, | ||
itemId: deletionRequestDo.itemId, | ||
status: deletionRequestDo.status, | ||
createdAt: deletionRequestDo.createdAt, | ||
updatedAt: deletionRequestDo.updatedAt, | ||
}; | ||
|
||
expect(gettersValues).toEqual(props); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
apps/server/src/modules/deletion/domain/testing/factory/deletion-log.factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { DoBaseFactory } from '@shared/testing'; | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { DeletionLog, DeletionLogProps } from '../../deletion-log.do'; | ||
import { DeletionOperationModel } from '../../types/deletion-operation-model.enum'; | ||
import { DeletionDomainModel } from '../../types/deletion-domain-model.enum'; | ||
|
||
export const deletionLogFactory = DoBaseFactory.define<DeletionLog, DeletionLogProps>(DeletionLog, () => { | ||
return { | ||
id: new ObjectId().toHexString(), | ||
domain: DeletionDomainModel.USER, | ||
operation: DeletionOperationModel.DELETE, | ||
modifiedCounter: 0, | ||
deletedCounter: 1, | ||
deletionRequestId: new ObjectId().toHexString(), | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
}); |
28 changes: 28 additions & 0 deletions
28
apps/server/src/modules/deletion/domain/testing/factory/deletion-request.factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { DoBaseFactory } from '@shared/testing'; | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { DeepPartial } from 'fishery'; | ||
import { DeletionRequest, DeletionRequestProps } from '../../deletion-request.do'; | ||
import { DeletionDomainModel } from '../../types/deletion-domain-model.enum'; | ||
import { DeletionStatusModel } from '../../types/deletion-status-model.enum'; | ||
|
||
class DeletionRequestFactory extends DoBaseFactory<DeletionRequest, DeletionRequestProps> { | ||
withUserIds(itemId: string): this { | ||
const params: DeepPartial<DeletionRequestProps> = { | ||
itemId, | ||
}; | ||
|
||
return this.params(params); | ||
} | ||
} | ||
|
||
export const deletionRequestFactory = DeletionRequestFactory.define(DeletionRequest, () => { | ||
return { | ||
id: new ObjectId().toHexString(), | ||
domain: DeletionDomainModel.USER, | ||
deleteAfter: new Date(), | ||
itemId: new ObjectId().toHexString(), | ||
status: DeletionStatusModel.REGISTERED, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
}); |
Oops, something went wrong.