import { Logger, Provider } from '@nestjs/common'

import { TestConfig_Test } from 'apps/api/src/api.config'

export class TestDataService {
  private logger = new Logger(TestDataService.name)

  constructor(public readonly config: TestConfig_Test) {}
  public resetTestData() {
    if (!this.config.isStateful) {
      throw new Error('TestDataService.resetTestData() was called but should not have been!')
    }
    this.logger.log('✅ Reset test data')
  }
}

export const provideTestDataService = (testConfig: TestConfig_Test): Provider<TestDataService> => ({
  provide: TestDataService,
  useValue: new TestDataService(testConfig),
})
