Skip to content

Commit

Permalink
👷 run tests tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mbaye THIAM committed Apr 15, 2024
1 parent a03a267 commit 1ed962e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
services:
registry:
image: registry:2
Expand Down Expand Up @@ -40,4 +43,18 @@ jobs:
platforms: linux/amd64

- name: Setup services for testing purpose
run: export IMAGE_TAG=localhost:5000/test/graphql-mesh:latest && cd ./test/integration && docker compose up -d
run: export IMAGE_TAG=localhost:5000/test/graphql-mesh:latest && cd ./test/integration && docker compose up

- name: Inspect network
run: docker network inspect integration_default

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: cd ./test/integration/tests && npm install

- name: Run tests
run: cd ./test/integration/tests && npm test
3 changes: 2 additions & 1 deletion test/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use a base image with Node.js
FROM node:18-alpine

RUN apk add curl

# Set the working directory inside the container
WORKDIR /app

Expand All @@ -10,7 +12,6 @@ COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the code to the working directory
COPY . .

Expand Down
11 changes: 10 additions & 1 deletion test/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ app.use('/api-docs/:file', (req, res) => {
})

// Redirect to the swagger UI
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(Yaml.load('./api-docs/swagger.yml')))
app.use(
'/api-products-docs',
swaggerUi.serve,
swaggerUi.setup(Yaml.load('./api-docs/products.yml'))
)
app.use(
'/api-suppliers-docs',
swaggerUi.serve,
swaggerUi.setup(Yaml.load('./api-docs/suppliers.yml'))
)

// Serve the products
app.get('/products', (req, res) => {
Expand Down
12 changes: 10 additions & 2 deletions test/integration/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ services:
build:
context: ../api/
dockerfile: ../api/Dockerfile
extra_hosts:
- "api-products:172.20.0.2"
#image: api-products
ports:
- 45537:5000
healthcheck:
test: curl --fail http://localhost:5000/products || exit 1
interval: 10s
timeout: 10s
retries: 3
restart: unless-stopped

# <http://localhost:45538/graphql>
graphql-mesh:
depends_on:
api-products:
condition: service_healthy
links:
- api-products
image: ${IMAGE_TAG:-bouyguestelecom/graphql-mesh:latest}
environment:
Expand Down
2 changes: 1 addition & 1 deletion test/integration/tests/get-products.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from 'vitest'
import axios from 'axios'

const url = 'http://127.0.0.1:45538/graphql'
const url = 'http://0.0.0.0:45538/graphql'
const headers = { 'Content-Type': 'application/json' }

/* Get all products */
Expand Down

0 comments on commit 1ed962e

Please sign in to comment.