-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added yml config for Green Metrics Tool and
associated test.
- Loading branch information
1 parent
d9f67c8
commit 6390544
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const request = require('supertest'); | ||
const expect = require('chai').expect; | ||
|
||
describe('Greencheck API', () => { | ||
it('Has the correct URL property', () => { | ||
request('https://django:8000') | ||
.get('/greencheck/climateaction.tech') | ||
.expect(200) | ||
.expect('Content-Type', 'application/json') | ||
.expect(function(res) { | ||
if (!res.body.hasOwnProperty('url')) throw new Error("Expected 'url' key!"); | ||
}) | ||
.end(function(err, res){ | ||
if (err) throw err; | ||
}) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "green_metric_tests", | ||
"version": "1.0.0", | ||
"description": "Integration tests for the Greencheck API, intended for use with the Green Metrics Tool from Green Code Berlin. (https://www.green-coding.io/projects/green-metrics-tool/)", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha '**/*.spec.js'" | ||
}, | ||
"author": "James Camilleri", | ||
"license": "SEE LICENSE IN ../LICENCE", | ||
"dependencies": { | ||
"chai": "^4.2.0", | ||
"mocha": "^10.4.0", | ||
"supertest": "^7.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
name: Greencheck Test | ||
author: James Camilleri <jcamilleri@scottlogic.com> | ||
description: Scenario to test the Greencheck endpoint of the Green Web Foundation Greencheck API | ||
|
||
version: "3.5" | ||
|
||
networks: | ||
greencheck-network: | ||
|
||
services: | ||
mariadb: | ||
image: mariadb:10.3 | ||
ports: | ||
- 3306:3306 | ||
env: | ||
MYSQL_ROOT_PASSWORD: just-for-github-actions | ||
MYSQL_DATABASE: greencheck | ||
networks: | ||
- greencheck-network | ||
|
||
rabbitmq: | ||
image: rabbitmq:3.9 | ||
env: | ||
RABBITMQ_USERNAME: "guest" | ||
RABBITMQ_PASSWORD: "guest" | ||
ports: | ||
- 5672:5672 | ||
options: '--hostname "rmq" --health-cmd "rabbitmqctl status" --health-interval 10s --health-timeout 10s --health-retries 3 --health-start-period 60s' | ||
networks: | ||
- greencheck-network | ||
|
||
django: | ||
depends_on: | ||
- mariadb | ||
build: | ||
context: . | ||
args: | ||
PIPENV_CFG: --dev | ||
command: | ||
- cp -a . . | ||
- python -m pip install --upgrade pipenv wheel | ||
- pipenv install --deploy --dev --verbose | ||
ports: | ||
- "8000:8000" | ||
restart: on-failure | ||
volumes: | ||
- .:/app | ||
stdin_open: true | ||
tty: true | ||
networks: | ||
- greencheck-network | ||
|
||
test-container: | ||
container_name: test-container | ||
image: node | ||
depends_on: django | ||
setup-commands: | ||
- cp ./green_metric_tests/greencheck_test.spec.js . | ||
- cp ./green_metric_tests/package.json . | ||
- npm install | ||
networks: | ||
- greencheck-network | ||
|
||
flow: | ||
- name: Greencheck API Test | ||
container: test-container | ||
commands: | ||
- type: console | ||
command: npm test | ||
note: Starting test | ||
read-notes-stdout: true | ||
- type: console | ||
command: sleep 30 | ||
note: Idling | ||
- type: console | ||
command: npm test | ||
note: Starting test again |