diff --git a/src/app.module.ts b/src/app.module.ts index 1ae6b0d853..5072501cb9 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -51,6 +51,7 @@ import { DelegatesV2Module } from '@/routes/delegates/v2/delegates.v2.module'; import { AccountsModule } from '@/routes/accounts/accounts.module'; import { NotificationsModuleV2 } from '@/routes/notifications/v2/notifications.module'; import { TargetedMessagingModule } from '@/routes/targeted-messaging/targeted-messaging.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; @Module({}) export class AppModule implements NestModule { @@ -71,6 +72,7 @@ export class AppModule implements NestModule { return { module: AppModule, imports: [ + PostgresDatabaseModule, // features AboutModule, ...(isAccountsFeatureEnabled ? [AccountsModule] : []), diff --git a/src/datasources/db/__tests__/test.postgres-database.module.ts b/src/datasources/db/__tests__/test.postgres-database.module.ts new file mode 100644 index 0000000000..7c937da8c7 --- /dev/null +++ b/src/datasources/db/__tests__/test.postgres-database.module.ts @@ -0,0 +1,16 @@ +import { Module } from '@nestjs/common'; + +/** + * The {@link TestPostgresDatabaseModule} should be used whenever you want to + * override the values provided by the {@link PostgresDatabase}. + * + * This will create a TestModule which uses the implementation of PostgresDatabase but + * overrides the real DB_INSTANCE with a null value. + * + */ +@Module({ + providers: [{ provide: 'DB_INSTANCE', useFactory: (): null => null }], + exports: [], + imports: [], +}) +export class TestPostgresDatabaseModule {} diff --git a/src/routes/about/__tests__/get-about.e2e-spec.ts b/src/routes/about/__tests__/get-about.e2e-spec.ts index 91296ff6df..76f08a6602 100644 --- a/src/routes/about/__tests__/get-about.e2e-spec.ts +++ b/src/routes/about/__tests__/get-about.e2e-spec.ts @@ -1,11 +1,13 @@ -import type { INestApplication } from '@nestjs/common'; -import { Test } from '@nestjs/testing'; -import request from 'supertest'; -import { AppModule } from '@/app.module'; -import { expect } from '@jest/globals'; import '@/__tests__/matchers/to-be-string-or-null'; +import { AppModule } from '@/app.module'; import { CacheKeyPrefix } from '@/datasources/cache/constants'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; +import { expect } from '@jest/globals'; +import type { INestApplication } from '@nestjs/common'; +import { Test } from '@nestjs/testing'; import type { Server } from 'net'; +import request from 'supertest'; describe('Get about e2e test', () => { let app: INestApplication; @@ -15,6 +17,8 @@ describe('Get about e2e test', () => { const moduleRef = await Test.createTestingModule({ imports: [AppModule.register()], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideProvider(CacheKeyPrefix) .useValue(cacheKeyPrefix) .compile(); diff --git a/src/routes/accounts/accounts.controller.spec.ts b/src/routes/accounts/accounts.controller.spec.ts index 3c4902ea09..6f7eff0ee0 100644 --- a/src/routes/accounts/accounts.controller.spec.ts +++ b/src/routes/accounts/accounts.controller.spec.ts @@ -8,6 +8,8 @@ import { TestCounterfactualSafesDataSourceModule } from '@/datasources/accounts/ import { CounterfactualSafesDatasourceModule } from '@/datasources/accounts/counterfactual-safes/counterfactual-safes.datasource.module'; import { TestCacheModule } from '@/datasources/cache/__tests__/test.cache.module'; import { CacheModule } from '@/datasources/cache/cache.module'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; import jwtConfiguration from '@/datasources/jwt/configuration/__tests__/jwt.configuration'; import { JWT_CONFIGURATION_MODULE, @@ -62,6 +64,8 @@ describe('AccountsController', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(JWT_CONFIGURATION_MODULE) .useModule(JwtConfigurationModule.register(jwtConfiguration)) .overrideModule(AccountsDatasourceModule) diff --git a/src/routes/alerts/alerts.controller.spec.ts b/src/routes/alerts/alerts.controller.spec.ts index 36c609c9e6..11bee7b99d 100644 --- a/src/routes/alerts/alerts.controller.spec.ts +++ b/src/routes/alerts/alerts.controller.spec.ts @@ -57,6 +57,8 @@ import { import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; // The `x-tenderly-signature` header contains a cryptographic signature. The webhook request signature is // a HMAC SHA256 hash of concatenated signing secret, request payload, and timestamp, in this order. @@ -102,6 +104,8 @@ describe('Alerts (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(JWT_CONFIGURATION_MODULE) .useModule(JwtConfigurationModule.register(jwtConfiguration)) .overrideModule(ALERTS_CONFIGURATION_MODULE) diff --git a/src/routes/auth/auth.controller.spec.ts b/src/routes/auth/auth.controller.spec.ts index 5d889ab74e..9c07e5bc11 100644 --- a/src/routes/auth/auth.controller.spec.ts +++ b/src/routes/auth/auth.controller.spec.ts @@ -36,6 +36,8 @@ import { IBlockchainApiManager, } from '@/domain/interfaces/blockchain-api.manager.interface'; import { TestBlockchainApiManagerModule } from '@/datasources/blockchain/__tests__/test.blockchain-api.manager'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; const verifySiweMessageMock = jest.fn(); @@ -49,6 +51,8 @@ describe('AuthController', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(config)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(JWT_CONFIGURATION_MODULE) .useModule(JwtConfigurationModule.register(jwtConfiguration)) .overrideModule(BlockchainApiManagerModule) diff --git a/src/routes/balances/balances.controller.spec.ts b/src/routes/balances/balances.controller.spec.ts index 8180924e0c..e94bfc259d 100644 --- a/src/routes/balances/balances.controller.spec.ts +++ b/src/routes/balances/balances.controller.spec.ts @@ -4,6 +4,8 @@ import { IConfigurationService } from '@/config/configuration.service.interface' import configuration from '@/config/entities/__tests__/configuration'; import { TestCacheModule } from '@/datasources/cache/__tests__/test.cache.module'; import { CacheModule } from '@/datasources/cache/cache.module'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; import { TestNetworkModule } from '@/datasources/network/__tests__/test.network.module'; import { NetworkResponseError } from '@/datasources/network/entities/network.error.entity'; import { NetworkModule } from '@/datasources/network/network.module'; @@ -48,6 +50,8 @@ describe('Balances Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/chains/chains.controller.spec.ts b/src/routes/chains/chains.controller.spec.ts index 2c23bd2071..cf1c21716c 100644 --- a/src/routes/chains/chains.controller.spec.ts +++ b/src/routes/chains/chains.controller.spec.ts @@ -37,6 +37,8 @@ import { } from '@/domain/interfaces/blockchain-api.manager.interface'; import { TestBlockchainApiManagerModule } from '@/datasources/blockchain/__tests__/test.blockchain-api.manager'; import type { FakeBlockchainApiManager } from '@/datasources/blockchain/__tests__/fake.blockchain-api.manager'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; const mockGetBlock = jest.fn(); describe('Chains Controller (Unit)', () => { @@ -65,6 +67,8 @@ describe('Chains Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/collectibles/collectibles.controller.spec.ts b/src/routes/collectibles/collectibles.controller.spec.ts index c0eb4a03f9..9f0b58152f 100644 --- a/src/routes/collectibles/collectibles.controller.spec.ts +++ b/src/routes/collectibles/collectibles.controller.spec.ts @@ -32,6 +32,8 @@ import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; import { getAddress } from 'viem'; import { safeBuilder } from '@/domain/safe/entities/__tests__/safe.builder'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Collectibles Controller (Unit)', () => { let app: INestApplication; @@ -53,6 +55,8 @@ describe('Collectibles Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/community/community.controller.spec.ts b/src/routes/community/community.controller.spec.ts index 7a5aa1f879..ea86d303e0 100644 --- a/src/routes/community/community.controller.spec.ts +++ b/src/routes/community/community.controller.spec.ts @@ -41,6 +41,8 @@ import { campaignActivityBuilder, toJson as campaignActivityToJson, } from '@/domain/community/entities/__tests__/campaign-activity.builder'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Community (Unit)', () => { let app: INestApplication; @@ -53,6 +55,8 @@ describe('Community (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/contracts/contracts.controller.spec.ts b/src/routes/contracts/contracts.controller.spec.ts index c4e6d967b2..4dc2c34373 100644 --- a/src/routes/contracts/contracts.controller.spec.ts +++ b/src/routes/contracts/contracts.controller.spec.ts @@ -20,6 +20,8 @@ import { NetworkResponseError } from '@/datasources/network/entities/network.err import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Contracts controller', () => { let app: INestApplication; @@ -32,6 +34,8 @@ describe('Contracts controller', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/delegates/delegates.controller.spec.ts b/src/routes/delegates/delegates.controller.spec.ts index f7089db943..04b6305c5b 100644 --- a/src/routes/delegates/delegates.controller.spec.ts +++ b/src/routes/delegates/delegates.controller.spec.ts @@ -27,6 +27,8 @@ import { getAddress } from 'viem'; import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Delegates controller', () => { let app: INestApplication; @@ -39,6 +41,8 @@ describe('Delegates controller', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/estimations/estimations.controller.spec.ts b/src/routes/estimations/estimations.controller.spec.ts index 4729277c10..64ad98d19b 100644 --- a/src/routes/estimations/estimations.controller.spec.ts +++ b/src/routes/estimations/estimations.controller.spec.ts @@ -28,6 +28,8 @@ import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues- import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; import { getAddress } from 'viem'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Estimations Controller (Unit)', () => { let app: INestApplication; @@ -40,6 +42,8 @@ describe('Estimations Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/health/health.controller.spec.ts b/src/routes/health/health.controller.spec.ts index 9782c94ff4..16082ebc8c 100644 --- a/src/routes/health/health.controller.spec.ts +++ b/src/routes/health/health.controller.spec.ts @@ -18,6 +18,8 @@ import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues- import type { IQueueReadiness } from '@/domain/interfaces/queue-readiness.interface'; import { QueueReadiness } from '@/domain/interfaces/queue-readiness.interface'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Health Controller tests', () => { let app: INestApplication; @@ -30,6 +32,8 @@ describe('Health Controller tests', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/hooks/hooks.controller.spec.ts b/src/routes/hooks/hooks.controller.spec.ts index fc818769d0..12a6967705 100644 --- a/src/routes/hooks/hooks.controller.spec.ts +++ b/src/routes/hooks/hooks.controller.spec.ts @@ -17,6 +17,8 @@ import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; import { NotificationsDatasourceModule } from '@/datasources/notifications/notifications.datasource.module'; import { TestNotificationsDatasourceModule } from '@/datasources/notifications/__tests__/test.notifications.datasource.module'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Post Hook Events (Unit)', () => { let app: INestApplication; @@ -27,6 +29,8 @@ describe('Post Hook Events (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(config)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/messages/messages.controller.spec.ts b/src/routes/messages/messages.controller.spec.ts index baf03114ad..49d91d40ab 100644 --- a/src/routes/messages/messages.controller.spec.ts +++ b/src/routes/messages/messages.controller.spec.ts @@ -32,6 +32,8 @@ import { NetworkResponseError } from '@/datasources/network/entities/network.err import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Messages controller', () => { let app: INestApplication; @@ -44,6 +46,8 @@ describe('Messages controller', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/notifications/v1/notifications.controller.spec.ts b/src/routes/notifications/v1/notifications.controller.spec.ts index 6ed4e760d5..3865ae3fde 100644 --- a/src/routes/notifications/v1/notifications.controller.spec.ts +++ b/src/routes/notifications/v1/notifications.controller.spec.ts @@ -24,6 +24,8 @@ import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues- import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; import { getAddress } from 'viem'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Notifications Controller (Unit)', () => { let app: INestApplication; @@ -36,6 +38,8 @@ describe('Notifications Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/notifications/v2/notifications.controller.spec.ts b/src/routes/notifications/v2/notifications.controller.spec.ts index 73c0656061..691898c804 100644 --- a/src/routes/notifications/v2/notifications.controller.spec.ts +++ b/src/routes/notifications/v2/notifications.controller.spec.ts @@ -44,6 +44,8 @@ import request from 'supertest'; import { getAddress } from 'viem'; import { CounterfactualSafesDatasourceModule } from '@/datasources/accounts/counterfactual-safes/counterfactual-safes.datasource.module'; import { TestCounterfactualSafesDataSourceModule } from '@/datasources/accounts/counterfactual-safes/__tests__/test.counterfactual-safes.datasource.module'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Notifications Controller V2 (Unit)', () => { let app: INestApplication; @@ -69,6 +71,8 @@ describe('Notifications Controller V2 (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(JWT_CONFIGURATION_MODULE) .useModule(JwtConfigurationModule.register(jwtConfiguration)) .overrideModule(AccountsDatasourceModule) diff --git a/src/routes/owners/owners.controller.spec.ts b/src/routes/owners/owners.controller.spec.ts index 1a129ab208..704ee6781c 100644 --- a/src/routes/owners/owners.controller.spec.ts +++ b/src/routes/owners/owners.controller.spec.ts @@ -25,6 +25,8 @@ import { import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; import { ChainsRepository } from '@/domain/chains/chains.repository'; describe('Owners Controller (Unit)', () => { @@ -38,6 +40,8 @@ describe('Owners Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/recovery/recovery.controller.spec.ts b/src/routes/recovery/recovery.controller.spec.ts index dc70a70eb9..0f2198b2cd 100644 --- a/src/routes/recovery/recovery.controller.spec.ts +++ b/src/routes/recovery/recovery.controller.spec.ts @@ -44,6 +44,8 @@ import type { Server } from 'net'; import { RecoveryController } from '@/routes/recovery/recovery.controller'; import { checkGuardIsApplied } from '@/__tests__/util/check-guard'; import { AuthGuard } from '@/routes/auth/guards/auth.guard'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Recovery (Unit)', () => { let app: INestApplication; @@ -70,6 +72,8 @@ describe('Recovery (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(JWT_CONFIGURATION_MODULE) .useModule(JwtConfigurationModule.register(jwtConfiguration)) .overrideModule(ALERTS_CONFIGURATION_MODULE) diff --git a/src/routes/relay/relay.controller.spec.ts b/src/routes/relay/relay.controller.spec.ts index ba0eb8c551..d2c238f7f4 100644 --- a/src/routes/relay/relay.controller.spec.ts +++ b/src/routes/relay/relay.controller.spec.ts @@ -51,6 +51,8 @@ import { getDeploymentVersionsByChainIds } from '@/__tests__/deployments.helper' import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; const supportedChainIds = faker.helpers.arrayElements( Object.keys(configuration().relay.apiKey), @@ -100,6 +102,8 @@ describe('Relay controller', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/root/root.controller.spec.ts b/src/routes/root/root.controller.spec.ts index df06ecfce0..8750c3dfea 100644 --- a/src/routes/root/root.controller.spec.ts +++ b/src/routes/root/root.controller.spec.ts @@ -10,6 +10,8 @@ import request from 'supertest'; import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Root Controller tests', () => { let app: INestApplication; @@ -18,6 +20,8 @@ describe('Root Controller tests', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(QueuesApiModule) diff --git a/src/routes/safe-apps/safe-apps.controller.spec.ts b/src/routes/safe-apps/safe-apps.controller.spec.ts index a028e76262..396cb334b6 100644 --- a/src/routes/safe-apps/safe-apps.controller.spec.ts +++ b/src/routes/safe-apps/safe-apps.controller.spec.ts @@ -22,6 +22,8 @@ import { NetworkService } from '@/datasources/network/network.service.interface' import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Safe Apps Controller (Unit)', () => { let app: INestApplication; @@ -34,6 +36,8 @@ describe('Safe Apps Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/safes/safes.controller.spec.ts b/src/routes/safes/safes.controller.spec.ts index 11b7045ade..5bdb04329c 100644 --- a/src/routes/safes/safes.controller.spec.ts +++ b/src/routes/safes/safes.controller.spec.ts @@ -41,6 +41,8 @@ import { getAddress } from 'viem'; import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Safes Controller (Unit)', () => { let app: INestApplication; @@ -53,6 +55,8 @@ describe('Safes Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/targeted-messaging/targeted-messaging.controller.spec.ts b/src/routes/targeted-messaging/targeted-messaging.controller.spec.ts index d97241aba4..cbf52b29dc 100644 --- a/src/routes/targeted-messaging/targeted-messaging.controller.spec.ts +++ b/src/routes/targeted-messaging/targeted-messaging.controller.spec.ts @@ -4,6 +4,8 @@ import { IConfigurationService } from '@/config/configuration.service.interface' import configuration from '@/config/entities/__tests__/configuration'; import { TestCacheModule } from '@/datasources/cache/__tests__/test.cache.module'; import { CacheModule } from '@/datasources/cache/cache.module'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; import jwtConfiguration from '@/datasources/jwt/configuration/jwt.configuration'; import { JWT_CONFIGURATION_MODULE, @@ -54,6 +56,8 @@ describe('TargetedMessagingController', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(JWT_CONFIGURATION_MODULE) .useModule(JwtConfigurationModule.register(jwtConfiguration)) .overrideModule(TargetedMessagingDatasourceModule) diff --git a/src/routes/transactions/__tests__/controllers/delete-transaction.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/delete-transaction.transactions.controller.spec.ts index 5aeea89dd6..ce686c8da0 100644 --- a/src/routes/transactions/__tests__/controllers/delete-transaction.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/delete-transaction.transactions.controller.spec.ts @@ -28,6 +28,8 @@ import type { FakeCacheService } from '@/datasources/cache/__tests__/fake.cache. import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Delete Transaction - Transactions Controller (Unit', () => { let app: INestApplication; @@ -41,6 +43,8 @@ describe('Delete Transaction - Transactions Controller (Unit', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/transactions/__tests__/controllers/get-creation-transaction.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/get-creation-transaction.transactions.controller.spec.ts index 5971029f5f..55002efd93 100644 --- a/src/routes/transactions/__tests__/controllers/get-creation-transaction.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/get-creation-transaction.transactions.controller.spec.ts @@ -4,6 +4,8 @@ import { IConfigurationService } from '@/config/configuration.service.interface' import configuration from '@/config/entities/__tests__/configuration'; import { TestCacheModule } from '@/datasources/cache/__tests__/test.cache.module'; import { CacheModule } from '@/datasources/cache/cache.module'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; import { TestNetworkModule } from '@/datasources/network/__tests__/test.network.module'; import { NetworkResponseError } from '@/datasources/network/entities/network.error.entity'; import { NetworkModule } from '@/datasources/network/network.module'; @@ -34,6 +36,8 @@ describe('Get creation transaction', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/transactions/__tests__/controllers/get-transaction-by-id.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/get-transaction-by-id.transactions.controller.spec.ts index fd25c5b69b..0549fb68e5 100644 --- a/src/routes/transactions/__tests__/controllers/get-transaction-by-id.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/get-transaction-by-id.transactions.controller.spec.ts @@ -40,6 +40,8 @@ import { getAddress } from 'viem'; import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Get by id - Transactions Controller (Unit)', () => { let app: INestApplication; @@ -52,6 +54,8 @@ describe('Get by id - Transactions Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/transactions/__tests__/controllers/list-incoming-transfers-by-safe.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/list-incoming-transfers-by-safe.transactions.controller.spec.ts index c8a6995247..4ac3a3372f 100644 --- a/src/routes/transactions/__tests__/controllers/list-incoming-transfers-by-safe.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/list-incoming-transfers-by-safe.transactions.controller.spec.ts @@ -37,6 +37,8 @@ import { getAddress } from 'viem'; import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('List incoming transfers by Safe - Transactions Controller (Unit)', () => { let app: INestApplication; @@ -49,6 +51,8 @@ describe('List incoming transfers by Safe - Transactions Controller (Unit)', () const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/transactions/__tests__/controllers/list-module-transactions-by-safe.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/list-module-transactions-by-safe.transactions.controller.spec.ts index 034d43d8e8..61f7cddf6f 100644 --- a/src/routes/transactions/__tests__/controllers/list-module-transactions-by-safe.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/list-module-transactions-by-safe.transactions.controller.spec.ts @@ -26,6 +26,8 @@ import { NetworkResponseError } from '@/datasources/network/entities/network.err import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('List module transactions by Safe - Transactions Controller (Unit)', () => { let app: INestApplication; @@ -38,6 +40,8 @@ describe('List module transactions by Safe - Transactions Controller (Unit)', () const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/transactions/__tests__/controllers/list-multisig-transactions-by-safe.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/list-multisig-transactions-by-safe.transactions.controller.spec.ts index 6e9a344e61..ff8e5896ce 100644 --- a/src/routes/transactions/__tests__/controllers/list-multisig-transactions-by-safe.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/list-multisig-transactions-by-safe.transactions.controller.spec.ts @@ -36,6 +36,8 @@ import { getAddress } from 'viem'; import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('List multisig transactions by Safe - Transactions Controller (Unit)', () => { let app: INestApplication; @@ -48,6 +50,8 @@ describe('List multisig transactions by Safe - Transactions Controller (Unit)', const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/transactions/__tests__/controllers/preview-transaction-cow-swap.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/preview-transaction-cow-swap.transactions.controller.spec.ts index 04d1b7f163..6a6c3a8d42 100644 --- a/src/routes/transactions/__tests__/controllers/preview-transaction-cow-swap.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/preview-transaction-cow-swap.transactions.controller.spec.ts @@ -32,6 +32,8 @@ import { multiSendEncoder, multiSendTransactionsEncoder, } from '@/domain/contracts/__tests__/encoders/multi-send-encoder.builder'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; describe('Preview transaction - CoW Swap - Transactions Controller (Unit)', () => { let app: INestApplication; @@ -62,6 +64,8 @@ describe('Preview transaction - CoW Swap - Transactions Controller (Unit)', () = const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/transactions/__tests__/controllers/preview-transaction-kiln.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/preview-transaction-kiln.transactions.controller.spec.ts index 5e45c53f7c..c0e76a3b4f 100644 --- a/src/routes/transactions/__tests__/controllers/preview-transaction-kiln.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/preview-transaction-kiln.transactions.controller.spec.ts @@ -44,6 +44,8 @@ import { multiSendEncoder, multiSendTransactionsEncoder, } from '@/domain/contracts/__tests__/encoders/multi-send-encoder.builder'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Preview transaction - Kiln - Transactions Controller (Unit)', () => { let app: INestApplication; @@ -66,6 +68,8 @@ describe('Preview transaction - Kiln - Transactions Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(testConfiguration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule) diff --git a/src/routes/transactions/__tests__/controllers/preview-transaction.transactions.controller.spec.ts b/src/routes/transactions/__tests__/controllers/preview-transaction.transactions.controller.spec.ts index c0c0b3164c..01ccf2e4e0 100644 --- a/src/routes/transactions/__tests__/controllers/preview-transaction.transactions.controller.spec.ts +++ b/src/routes/transactions/__tests__/controllers/preview-transaction.transactions.controller.spec.ts @@ -28,6 +28,8 @@ import { getAddress } from 'viem'; import { TestQueuesApiModule } from '@/datasources/queues/__tests__/test.queues-api.module'; import { QueuesApiModule } from '@/datasources/queues/queues-api.module'; import type { Server } from 'net'; +import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module'; +import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; describe('Preview transaction - Transactions Controller (Unit)', () => { let app: INestApplication; @@ -40,6 +42,8 @@ describe('Preview transaction - Transactions Controller (Unit)', () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule.register(configuration)], }) + .overrideModule(PostgresDatabaseModule) + .useModule(TestPostgresDatabaseModule) .overrideModule(CacheModule) .useModule(TestCacheModule) .overrideModule(RequestScopedLoggingModule)