Skip to content

Commit

Permalink
mock postgres database v1 in more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PooyaRaki committed Oct 27, 2024
1 parent 1f7af10 commit c556579
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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/v1/postgres-database.module';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import jwtConfiguration from '@/datasources/jwt/configuration/__tests__/jwt.configuration';
Expand Down Expand Up @@ -80,6 +82,8 @@ describe('CounterfactualSafesController', () => {
.useModule(TestQueuesApiModule)
.overrideModule(PostgresDatabaseModuleV2)
.useModule(TestPostgresDatabaseModuleV2)
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.compile();
jwtService = moduleFixture.get<IJwtService>(IJwtService);
accountsRepository = moduleFixture.get(IAccountsDatasource);
Expand Down
2 changes: 2 additions & 0 deletions src/routes/alerts/alerts.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ describe('Alerts (Unit)', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(testConfiguration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { sample } from 'lodash';
import { balancesProviderBuilder } from '@/domain/chains/entities/__tests__/balances-provider.builder';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';

describe('Balances Controller (Unit)', () => {
let app: INestApplication<Server>;
Expand Down Expand Up @@ -71,6 +73,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)
Expand Down
4 changes: 4 additions & 0 deletions src/routes/chains/chains.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { BlockchainApiManagerModule } from '@/domain/interfaces/blockchain-api.m
import { TestBlockchainApiManagerModule } from '@/datasources/blockchain/__tests__/test.blockchain-api.manager';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

describe('Chains Controller (Unit)', () => {
let app: INestApplication<Server>;
Expand All @@ -60,6 +62,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import type { Server } from 'net';
import { balancesProviderBuilder } from '@/domain/chains/entities/__tests__/balances-provider.builder';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

describe('Zerion Collectibles Controller', () => {
let app: INestApplication<Server>;
Expand All @@ -43,6 +45,8 @@ describe('Zerion Collectibles Controller', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(configuration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
4 changes: 4 additions & 0 deletions src/routes/delegates/v2/delegates.v2.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/v1/postgres-database.module';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { TestNetworkModule } from '@/datasources/network/__tests__/test.network.module';
Expand Down Expand Up @@ -49,6 +51,8 @@ describe('Delegates controller', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(testConfiguration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
4 changes: 4 additions & 0 deletions src/routes/hooks/hooks-cache.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { KilnDecoder } from '@/domain/staking/contracts/decoders/kiln-decoder.he
import { stakeBuilder } from '@/datasources/staking-api/entities/__tests__/stake.entity.builder';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

// TODO: Migrate to E2E tests as TransactionEventType events are already being received via queue.
describe.skip('Post Hook Events for Cache (Unit)', () => {
Expand All @@ -50,6 +52,8 @@ describe.skip('Post Hook Events for Cache (Unit)', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(config)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
4 changes: 4 additions & 0 deletions src/routes/hooks/hooks-notifications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ import {
import jwtConfiguration from '@/datasources/jwt/configuration/__tests__/jwt.configuration';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

// TODO: Migrate to E2E tests as TransactionEventType events are already being received via queue.
describe.skip('Post Hook Events for Notifications (Unit)', () => {
Expand All @@ -83,6 +85,8 @@ describe.skip('Post Hook Events for Notifications (Unit)', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(testConfiguration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(JWT_CONFIGURATION_MODULE)
.useModule(JwtConfigurationModule.register(jwtConfiguration))
.overrideModule(CacheModule)
Expand Down
4 changes: 4 additions & 0 deletions src/routes/safes/safes.controller.nonces.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { QueuesApiModule } from '@/datasources/queues/queues-api.module';
import type { Server } from 'net';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

describe('Safes Controller Nonces (Unit)', () => {
let app: INestApplication<Server>;
Expand All @@ -39,6 +41,8 @@ describe('Safes Controller Nonces (Unit)', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(configuration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
4 changes: 4 additions & 0 deletions src/routes/safes/safes.controller.overview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { QueuesApiModule } from '@/datasources/queues/queues-api.module';
import type { Server } from 'net';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

describe('Safes Controller Overview (Unit)', () => {
let app: INestApplication<Server>;
Expand Down Expand Up @@ -60,6 +62,8 @@ describe('Safes Controller Overview (Unit)', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(testConfiguration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { QueuesApiModule } from '@/datasources/queues/queues-api.module';
import type { Server } from 'net';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

describe('Propose transaction - Transactions Controller (Unit)', () => {
let app: INestApplication<Server>;
Expand All @@ -44,6 +46,8 @@ describe('Propose transaction - Transactions Controller (Unit)', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(configuration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ import { QueuesApiModule } from '@/datasources/queues/queues-api.module';
import type { Server } from 'net';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

describe('Transactions History Controller (Unit)', () => {
let app: INestApplication<Server>;
Expand All @@ -85,6 +87,8 @@ describe('Transactions History Controller (Unit)', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(testConfiguration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import type { MultisigTransaction } from '@/domain/safe/entities/multisig-transa
import type { Server } from 'net';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { PostgresDatabaseModule } from '@/datasources/db/v1/postgres-database.module';
import { TestPostgresDatabaseModule } from '@/datasources/db/__tests__/test.postgres-database.module';

describe('Transactions History Controller (Unit) - Imitation Transactions', () => {
let app: INestApplication<Server>;
Expand Down Expand Up @@ -88,6 +90,8 @@ describe('Transactions History Controller (Unit) - Imitation Transactions', () =
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(testConfiguration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down
4 changes: 4 additions & 0 deletions src/routes/transactions/transactions-view.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/v1/postgres-database.module';
import { PostgresDatabaseModuleV2 } from '@/datasources/db/v2/postgres-database.module';
import { TestPostgresDatabaseModuleV2 } from '@/datasources/db/v2/test.postgres-database.module';
import { TestNetworkModule } from '@/datasources/network/__tests__/test.network.module';
Expand Down Expand Up @@ -72,6 +74,8 @@ describe('TransactionsViewController tests', () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule.register(testConfiguration)],
})
.overrideModule(PostgresDatabaseModule)
.useModule(TestPostgresDatabaseModule)
.overrideModule(CacheModule)
.useModule(TestCacheModule)
.overrideModule(RequestScopedLoggingModule)
Expand Down

0 comments on commit c556579

Please sign in to comment.