chore(server): refactor locks (#5953)

* lock refactor

* add mocks

* add await

* move database repo injection to service

* update tests

* add mock implementation

* remove unused imports

* this
This commit is contained in:
Mert
2023-12-27 18:36:51 -05:00
committed by GitHub
parent 1af27fcc47
commit 8119d4bb26
11 changed files with 90 additions and 72 deletions
@@ -2,6 +2,7 @@ import { AssetEntity, SystemConfigKey } from '@app/infra/entities';
import {
assetStub,
newAssetRepositoryMock,
newDatabaseRepositoryMock,
newJobRepositoryMock,
newMachineLearningRepositoryMock,
newSmartInfoRepositoryMock,
@@ -10,6 +11,7 @@ import {
import { JobName } from '../job';
import {
IAssetRepository,
IDatabaseRepository,
IJobRepository,
IMachineLearningRepository,
ISmartInfoRepository,
@@ -31,6 +33,7 @@ describe(SmartInfoService.name, () => {
let jobMock: jest.Mocked<IJobRepository>;
let smartMock: jest.Mocked<ISmartInfoRepository>;
let machineMock: jest.Mocked<IMachineLearningRepository>;
let databaseMock: jest.Mocked<IDatabaseRepository>;
beforeEach(async () => {
assetMock = newAssetRepositoryMock();
@@ -38,7 +41,8 @@ describe(SmartInfoService.name, () => {
smartMock = newSmartInfoRepositoryMock();
jobMock = newJobRepositoryMock();
machineMock = newMachineLearningRepositoryMock();
sut = new SmartInfoService(assetMock, configMock, jobMock, smartMock, machineMock);
databaseMock = newDatabaseRepositoryMock();
sut = new SmartInfoService(assetMock, databaseMock, jobMock, machineMock, smartMock, configMock);
assetMock.getByIds.mockResolvedValue([asset]);
});