feat(api): add automatic DI to analytics module

This commit is contained in:
yassinedorbozgithub 2025-06-16 07:14:07 +01:00
parent 4d16e330d7
commit e7ae9a82d9
3 changed files with 11 additions and 29 deletions

View File

@ -6,8 +6,6 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { MongooseModule } from '@nestjs/mongoose';
import { import {
botstatsFixtures, botstatsFixtures,
installBotStatsFixtures, installBotStatsFixtures,
@ -18,9 +16,7 @@ import {
} from '@/utils/test/test'; } from '@/utils/test/test';
import { buildTestingMocks } from '@/utils/test/utils'; import { buildTestingMocks } from '@/utils/test/utils';
import { BotStatsRepository } from '../repositories/bot-stats.repository'; import { BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsModel, BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsService } from '../services/bot-stats.service';
import { BotStatsController } from './bot-stats.controller'; import { BotStatsController } from './bot-stats.controller';
@ -29,12 +25,9 @@ describe('BotStatsController', () => {
beforeAll(async () => { beforeAll(async () => {
const { getMocks } = await buildTestingMocks({ const { getMocks } = await buildTestingMocks({
autoInjectFrom: ['controllers'],
controllers: [BotStatsController], controllers: [BotStatsController],
imports: [ imports: [rootMongooseTestModule(installBotStatsFixtures)],
rootMongooseTestModule(installBotStatsFixtures),
MongooseModule.forFeature([BotStatsModel]),
],
providers: [BotStatsService, BotStatsRepository],
}); });
[botStatsController] = await getMocks([BotStatsController]); [botStatsController] = await getMocks([BotStatsController]);
}); });

View File

@ -6,7 +6,7 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { getModelToken, MongooseModule } from '@nestjs/mongoose'; import { getModelToken } from '@nestjs/mongoose';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
import { import {
@ -19,11 +19,7 @@ import {
} from '@/utils/test/test'; } from '@/utils/test/test';
import { buildTestingMocks } from '@/utils/test/utils'; import { buildTestingMocks } from '@/utils/test/utils';
import { import { BotStats, BotStatsType } from '../schemas/bot-stats.schema';
BotStats,
BotStatsModel,
BotStatsType,
} from '../schemas/bot-stats.schema';
import { BotStatsRepository } from './bot-stats.repository'; import { BotStatsRepository } from './bot-stats.repository';
@ -33,10 +29,8 @@ describe('BotStatsRepository', () => {
beforeAll(async () => { beforeAll(async () => {
const { getMocks } = await buildTestingMocks({ const { getMocks } = await buildTestingMocks({
imports: [ autoInjectFrom: ['providers'],
rootMongooseTestModule(installBotStatsFixtures), imports: [rootMongooseTestModule(installBotStatsFixtures)],
MongooseModule.forFeature([BotStatsModel]),
],
providers: [BotStatsRepository], providers: [BotStatsRepository],
}); });
[botStatsRepository, botStatsModel] = await getMocks([ [botStatsRepository, botStatsModel] = await getMocks([

View File

@ -6,8 +6,6 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { MongooseModule } from '@nestjs/mongoose';
import { import {
botstatsFixtures, botstatsFixtures,
installBotStatsFixtures, installBotStatsFixtures,
@ -18,8 +16,7 @@ import {
} from '@/utils/test/test'; } from '@/utils/test/test';
import { buildTestingMocks } from '@/utils/test/utils'; import { buildTestingMocks } from '@/utils/test/utils';
import { BotStatsRepository } from '../repositories/bot-stats.repository'; import { BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsModel, BotStatsType } from '../schemas/bot-stats.schema';
import { BotStatsService } from './bot-stats.service'; import { BotStatsService } from './bot-stats.service';
@ -28,11 +25,9 @@ describe('BotStatsService', () => {
beforeAll(async () => { beforeAll(async () => {
const { getMocks } = await buildTestingMocks({ const { getMocks } = await buildTestingMocks({
imports: [ autoInjectFrom: ['providers'],
rootMongooseTestModule(installBotStatsFixtures), imports: [rootMongooseTestModule(installBotStatsFixtures)],
MongooseModule.forFeature([BotStatsModel]), providers: [BotStatsService],
],
providers: [BotStatsService, BotStatsRepository],
}); });
[botStatsService] = await getMocks([BotStatsService]); [botStatsService] = await getMocks([BotStatsService]);
}); });