mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
fix: basic test fixed
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { FileModificationService } from './unraid-file-modifier.service';
|
||||
|
||||
import { UnraidFileModificationService } from './unraid-file-modifier.service';
|
||||
|
||||
@Module({
|
||||
providers: [FileModificationService]
|
||||
providers: [UnraidFileModificationService],
|
||||
})
|
||||
export class UnraidFileModifierModule {}
|
||||
|
||||
@@ -19,8 +19,8 @@ export interface FileModification {
|
||||
|
||||
// Step 2: Create a FileModificationService
|
||||
@Injectable()
|
||||
export class FileModificationService implements OnModuleInit, OnModuleDestroy {
|
||||
private readonly logger = new Logger(FileModificationService.name);
|
||||
export class UnraidFileModificationService implements OnModuleInit, OnModuleDestroy {
|
||||
private readonly logger = new Logger(UnraidFileModificationService.name);
|
||||
private history: FileModification[] = []; // Keeps track of applied modifications
|
||||
|
||||
async onModuleInit() {
|
||||
@@ -71,12 +71,16 @@ export class FileModificationService implements OnModuleInit, OnModuleDestroy {
|
||||
try {
|
||||
const shouldApplyWithReason = await modification.shouldApply();
|
||||
if (shouldApplyWithReason.shouldApply) {
|
||||
this.logger.log(`Applying modification: ${modification.id} - ${shouldApplyWithReason.reason}`);
|
||||
this.logger.log(
|
||||
`Applying modification: ${modification.id} - ${shouldApplyWithReason.reason}`
|
||||
);
|
||||
await modification.apply();
|
||||
this.history.push(modification); // Store modification in history
|
||||
this.logger.log(`Modification applied successfully: ${modification.id}`);
|
||||
} else {
|
||||
this.logger.log(`Skipping modification: ${modification.id} - ${shouldApplyWithReason.reason}`);
|
||||
this.logger.log(
|
||||
`Skipping modification: ${modification.id} - ${shouldApplyWithReason.reason}`
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { UnraidFileModifierService } from './unraid-file-modifier.service';
|
||||
import { UnraidFileModificationService } from '@app/unraid-api/unraid-file-modifier/unraid-file-modifier.service';
|
||||
|
||||
describe('FileModificationService', () => {
|
||||
let service: UnraidFileModifierService;
|
||||
let service: UnraidFileModificationService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [UnraidFileModifierService],
|
||||
providers: [UnraidFileModificationService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<UnraidFileModifierService>(UnraidFileModifierService);
|
||||
service = module.get<UnraidFileModificationService>(UnraidFileModificationService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
|
||||
Reference in New Issue
Block a user