Skip to content

Commit

Permalink
test: run test ci on pr lvl, fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmrdlt committed Mar 20, 2024
1 parent 64b24c0 commit 16ec380
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ on:
- main
tags:
- 'v*'
pull_request:
branches: [ main ]
types: [ opened ]
pull_request: {}

jobs:
main:
Expand All @@ -31,21 +29,18 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 100

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

- name: npm install
run: npm ci

- name: npm lint
run: npm run lint

- name: unit test
run: npm run test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CREATE UNIQUE INDEX "PairLiquidityInfoHistory_pairId_microBlockHash_key" ON "Pai
CREATE UNIQUE INDEX "PairLiquidityInfoHistoryError_pairId_microBlockHash_error_key" ON "PairLiquidityInfoHistoryError"("pairId", "microBlockHash", "error");

-- AddForeignKey
ALTER TABLE "PairLiquidityInfoHistory" ADD CONSTRAINT "PairLiquidityInfoHistory_pairId_fkey" FOREIGN KEY ("pairId") REFERENCES "Pair"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "PairLiquidityInfoHistory" ADD CONSTRAINT "PairLiquidityInfoHistory_pairId_fkey" FOREIGN KEY ("pairId") REFERENCES "Pair"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "PairLiquidityInfoHistoryError" ADD CONSTRAINT "PairLiquidityInfoHistoryError_pairId_fkey" FOREIGN KEY ("pairId") REFERENCES "Pair"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "PairLiquidityInfoHistoryError" ADD CONSTRAINT "PairLiquidityInfoHistoryError_pairId_fkey" FOREIGN KEY ("pairId") REFERENCES "Pair"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ model PairLiquidityInfoHistory {

model PairLiquidityInfoHistoryError {
id Int @id @default(autoincrement())
pair Pair @relation(fields: [pairId], references: [id])
pair Pair @relation(fields: [pairId], references: [id], onDelete: Cascade)
pairId Int
microBlockHash String
error String
Expand Down
7 changes: 4 additions & 3 deletions test/pairs.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';
import { mockContext, listToken, sortByAddress } from './utils';
import { listToken, mockContext, sortByAddress } from './utils';
import createWorkerMethods from '../src/worker';
import * as data from './data/context-mockups';
import * as db from './utils/db';
import { TokensModule } from '../src/api/tokens/module';
import { PairsModule } from '../src/api/pairs/module';

type WorkerMethods = ReturnType<typeof createWorkerMethods>;
let activeWorker: WorkerMethods;
Expand All @@ -29,7 +30,7 @@ describe('pairs fetching (e2e)', () => {

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
imports: [TokensModule, PairsModule],
}).compile();

app = moduleFixture.createNestApplication();
Expand Down
7 changes: 4 additions & 3 deletions test/swap-routes.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';

import { mockContext, listToken } from './utils';
import { listToken, mockContext } from './utils';
import worker from '../src/worker';
import * as db from './utils/db';
import * as data from './data/context-mockups';
import { TokensModule } from '../src/api/tokens/module';
import { PairsModule } from '../src/api/pairs/module';

type WorkerMethods = ReturnType<typeof worker>;
let activeWorker: WorkerMethods;
Expand All @@ -28,7 +29,7 @@ const initWorker = async (dataCtx: any) => {

const initApp = async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
imports: [TokensModule, PairsModule],
}).compile();

app = moduleFixture.createNestApplication();
Expand Down
7 changes: 4 additions & 3 deletions test/tokens.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';

import worker from '../src/worker';
import { clean as cleanDb } from './utils/db';
import * as data from './data/context-mockups';
import * as dto from '../src/dto';
import * as utils from './utils';
import { nonNullable } from '../src/lib/utils';
import { TokensModule } from '../src/api/tokens/module';
import { PairsModule } from '../src/api/pairs/module';

type WorkerMethods = ReturnType<typeof worker>;
let activeWorker: WorkerMethods;
Expand All @@ -32,7 +33,7 @@ describe('tokens fetching (e2e)', () => {

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
imports: [TokensModule, PairsModule],
}).compile();

app = moduleFixture.createNestApplication();
Expand Down Expand Up @@ -486,7 +487,7 @@ describe('listed tokens management (e2e)', () => {

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
imports: [TokensModule, PairsModule],
}).compile();

app = moduleFixture.createNestApplication();
Expand Down

0 comments on commit 16ec380

Please sign in to comment.