auto-tdd 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +4 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- package/.github/workflows/main.yml +72 -0
- package/.nvmrc +1 -0
- package/LICENSE +674 -0
- package/README.md +24 -0
- package/TODO +17 -0
- package/adapters/Adapter.js +5 -0
- package/adapters/AdapterThing.spec.js +10 -0
- package/cucumber.js +3 -0
- package/docker-compose.yml +21 -0
- package/domain/Thing.port.js +5 -0
- package/domain/calculator.js +9 -0
- package/domain/domain.spec.js +14 -0
- package/domain/javascript-user-interface.js +22 -0
- package/domain/test-cases/all.js +5 -0
- package/domain/test-cases/sum.js +26 -0
- package/domain/test-cases/test-user.js +22 -0
- package/features/simple_math.feature +37 -0
- package/features/support/steps.js +15 -0
- package/features/support/transform.js +16 -0
- package/features/support/world.js +22 -0
- package/http-api/Dockerfile +21 -0
- package/http-api/healthcheck.js +36 -0
- package/http-api/start.js +26 -0
- package/lambda-function/Dockerfile +16 -0
- package/lambda-function/app.js +8 -0
- package/package.json +58 -0
- package/publish-on-docker-hub.sh +13 -0
- package/renovate.json +4 -0
- package/stryker.conf.js +13 -0
- package/test-doubles/FakeThing.spec.js +3 -0
- package/test-http-api/container-test-cases.js +19 -0
- package/test-http-api/delay.js +3 -0
- package/test-http-api/docker-compose.component.spec.js +33 -0
- package/test-http-api/docker.component.spec.js +40 -0
- package/test-http-api/http-api-user-interface.js +12 -0
- package/test-http-api/runCommand.js +12 -0
- package/test-integration/TestingThingDoesStuff.spec.js +3 -0
- package/test-lambda-function/delay.js +3 -0
- package/test-lambda-function/docker.component.spec.js +55 -0
- package/test-lambda-function/runCommand.js +12 -0
- package/test-lambda-function/testing-lambda-function-user-interface.js +13 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const uuid = require('uuid');
|
|
2
|
+
const {expect} = require('chai');
|
|
3
|
+
const axios = require('axios');
|
|
4
|
+
const runCommand = require('./runCommand');
|
|
5
|
+
const delay = require('./delay');
|
|
6
|
+
const domain_tests = require('../domain/test-cases/all.js');
|
|
7
|
+
const user_interface = require('./testing-lambda-function-user-interface')()
|
|
8
|
+
|
|
9
|
+
describe('Lambda container tests', function () {
|
|
10
|
+
this.timeout(70000);
|
|
11
|
+
const image_name = 'auto-test-lambda-image'
|
|
12
|
+
async function buildProductionImage(){
|
|
13
|
+
await runCommand(`docker build -t ${image_name} -f ./lambda-function/Dockerfile .`, `built ${image_name}`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function runContainer(containerId){
|
|
17
|
+
await runCommand(`docker run -d -p 3000:8080 --name ${containerId} ${image_name}`, `created container ${containerId}`)
|
|
18
|
+
await delay(1000) //TODO add this wait to the create command
|
|
19
|
+
// await runCommand(`docker logs ${containerId}`, `logs for container ${containerId}: \n`) //TODO: show the logs and fail in case there are errors
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function removeContainer(containerId){
|
|
23
|
+
await runCommand(`docker rm -f ${containerId}`, `removed container ${containerId}`)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
before(async () => { //beforeAll
|
|
27
|
+
this.containerId = uuid.v4()
|
|
28
|
+
await buildProductionImage()
|
|
29
|
+
await runContainer(this.containerId)
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
after(async () => { //afterAll
|
|
33
|
+
await removeContainer(this.containerId)
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should build and run the container', () => {});
|
|
37
|
+
|
|
38
|
+
it('should respond to invocation', async () => {
|
|
39
|
+
let response = await axios.post('http://localhost:3000/2015-03-31/functions/function/invocations', '{}')
|
|
40
|
+
expect(response.status).to.equal(200)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('should return content', async () => {
|
|
44
|
+
let response = await axios.post('http://localhost:3000/2015-03-31/functions/function/invocations', '{}')
|
|
45
|
+
expect(response.data).not.to.be.undefined
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
xit('play with the container before removing it', async () => {
|
|
49
|
+
console.log("container deployed")
|
|
50
|
+
await delay(60000)
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
//TODO: pass a testscenario with preArrange, postArrange, preAct, postAct, preAssert, postAssert methods
|
|
54
|
+
domain_tests(user_interface);
|
|
55
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
|
|
3
|
+
module.exports = async function runCommand(command, reason){
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
exec(command, (error, stdout) => {
|
|
6
|
+
if (error) return reject(error)
|
|
7
|
+
//console.log(reason)
|
|
8
|
+
//console.log(stdout)
|
|
9
|
+
resolve();
|
|
10
|
+
});
|
|
11
|
+
})
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
module.exports = function(){
|
|
4
|
+
return Object.freeze({
|
|
5
|
+
sum
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
async function sum(a, b){
|
|
9
|
+
const response = await axios.post('http://localhost:3000/2015-03-31/functions/function/invocations', `{"a": ${a}, "b": ${b}}`)
|
|
10
|
+
//console.log(response)
|
|
11
|
+
return response.data
|
|
12
|
+
}
|
|
13
|
+
}
|