From 7aa5760565712b29eb3432a4258073bf8a743cd0 Mon Sep 17 00:00:00 2001 From: Yadd Date: Fri, 16 Aug 2024 21:40:08 +0400 Subject: [PATCH] Harmonize test --- uwsgi-portal/__test__/Dockerfile | 2 +- uwsgi-portal/__test__/docker-compose.yml | 14 +++++++++++++- uwsgi-portal/__test__/portal.test.js | 10 +++++++--- uwsgi-portal/__test__/server/Dockerfile | 7 +++++++ uwsgi-portal/__test__/server/index.js | 9 +++++++++ 5 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 uwsgi-portal/__test__/server/Dockerfile create mode 100644 uwsgi-portal/__test__/server/index.js diff --git a/uwsgi-portal/__test__/Dockerfile b/uwsgi-portal/__test__/Dockerfile index b6b2381..6984468 100644 --- a/uwsgi-portal/__test__/Dockerfile +++ b/uwsgi-portal/__test__/Dockerfile @@ -6,4 +6,4 @@ RUN mkdir /test COPY *.test.js /test/ -CMD [ "mocha", "-t", "30000", "/test/*.test.js" ] +CMD [ "mocha", "--exit", "-t", "30000", "/test/*.test.js" ] diff --git a/uwsgi-portal/__test__/docker-compose.yml b/uwsgi-portal/__test__/docker-compose.yml index 6c298a4..a4703b3 100644 --- a/uwsgi-portal/__test__/docker-compose.yml +++ b/uwsgi-portal/__test__/docker-compose.yml @@ -1,13 +1,25 @@ version: "3.4" services: + relay: + image: yadd/relay-test + build: + context: ./server + networks: + uportaltest: + aliases: + - relay.example.com + auth.example.com: container_name: test_portal_with_supertest image: yadd/lemonldap-ng-portal environment: - LOGGER=stderr - USERLOGGER=stderr - - "RELAY=foo.example.com=http://auth.example.com/static/" + - "RELAY=foo.example.com=http://relay.example.com:3000/" + depends_on: + relay: + condition: service_started networks: uportaltest: aliases: diff --git a/uwsgi-portal/__test__/portal.test.js b/uwsgi-portal/__test__/portal.test.js index 0e81521..59e43dd 100755 --- a/uwsgi-portal/__test__/portal.test.js +++ b/uwsgi-portal/__test__/portal.test.js @@ -55,10 +55,14 @@ describe('LLNG portal', () => { }) describe('RELAY', () => { const request = supertest.agent('http://foo.example.com') - it('should find /languages/fr.json', (done) => { - request.get('/languages/fr.json') + it('should find http://foo.example.com/', (done) => { + request.get('/') + .set('Accept', 'application/json') .expect(200) - .then(res => { done() }) + .expect({name:'john'}) + .then(res => { + done(); + }) .catch(done) }); }) diff --git a/uwsgi-portal/__test__/server/Dockerfile b/uwsgi-portal/__test__/server/Dockerfile new file mode 100644 index 0000000..f815c74 --- /dev/null +++ b/uwsgi-portal/__test__/server/Dockerfile @@ -0,0 +1,7 @@ +FROM debian:bookworm-slim + +RUN apt-get update && apt-get upgrade -y && apt-get install -y node-express + +COPY index.js / + +CMD ["node","/index.js"] diff --git a/uwsgi-portal/__test__/server/index.js b/uwsgi-portal/__test__/server/index.js new file mode 100644 index 0000000..379f9fd --- /dev/null +++ b/uwsgi-portal/__test__/server/index.js @@ -0,0 +1,9 @@ +#!/usr/bin/node + +const express = require('express'); + +const app = express(); +app.get('/', function (req, res) { + res.status(200).json({ name: 'john' }); +}) +app.listen(3000)