This repository has been archived by the owner on Dec 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
356 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 |
---|---|---|
|
@@ -24,3 +24,4 @@ main | |
.r.logs.log | ||
server.log | ||
*/_tmp* | ||
*/node_modules |
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
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,66 @@ | ||
const assert = require('assert') | ||
const sendRequest = require('../util/sendRequest') | ||
|
||
const template = { | ||
name: "integration-test-client", | ||
appIdentifier: "integration.test", | ||
clientType: "android" | ||
} | ||
|
||
describe('initially', () => { | ||
it('should have no mobile clients present', async () => { | ||
const res = await sendRequest('GET', 'mobileclients') | ||
assert.equal(res.status, 200) | ||
assert.equal(res.data.items.length, 0) | ||
}); | ||
}); | ||
|
||
describe('when creating a new client', () => { | ||
let res; | ||
it('should be created without error', async () => { | ||
res = await sendRequest('POST', 'mobileclients', template) | ||
assert.equal(res.status, 200) | ||
}); | ||
|
||
it('created client should have required metadata', () => { | ||
assert.equal(res.data.metadata.name, template.name) | ||
assert.equal(res.data.spec.name, template.name) | ||
assert.equal(res.data.spec.clientType, template.clientType) | ||
assert.equal(res.data.spec.appIdentifier, template.appIdentifier) | ||
assert.equal(res.data.status.clientId, template.name) | ||
}); | ||
|
||
}); | ||
|
||
describe('when listing a client', () => { | ||
let res; | ||
it('should be listed without error', async () => { | ||
res = await sendRequest('GET', 'mobileclients') | ||
assert.equal(res.status, 200) | ||
}); | ||
|
||
it('listed client should have required metadata', () => { | ||
const listedClientData = res.data.items[0] | ||
assert.equal(listedClientData.metadata.name, template.name) | ||
assert.equal(listedClientData.spec.name, template.name) | ||
assert.equal(listedClientData.spec.clientType, template.clientType) | ||
assert.equal(listedClientData.spec.appIdentifier, template.appIdentifier) | ||
assert.equal(listedClientData.status.clientId, template.name) | ||
}); | ||
|
||
}); | ||
|
||
describe('when deleting a client', () => { | ||
let res; | ||
it('should be deleted without error', async () => { | ||
res = await sendRequest('DELETE', `mobileclients/${template.name}`) | ||
assert.equal(res.status, 200) | ||
}); | ||
|
||
it('deleted client should be no longer present in the list', async () => { | ||
res = await sendRequest('GET', 'mobileclients') | ||
assert.equal(res.status, 200) | ||
assert.equal(res.data.items.length, 0) | ||
}); | ||
|
||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
{ | ||
"name": "mdc-integration-tests", | ||
"description": "Integration tests for MDC", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"test": "mocha ." | ||
}, | ||
"devDependencies": { | ||
"axios": "^0.18.0", | ||
"mocha": "^5.2.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,30 @@ | ||
const { exec } = require('child_process') | ||
|
||
process.env.NAMESPACE = process.env.NAMESPACE || "mdc-integration-testing" | ||
process.env.KUBERNETES_CONFIG = process.env.KUBERNETES_CONFIG || `${process.env.HOME}/.kube/config` | ||
|
||
let goOutput | ||
|
||
// Spin up backend server on port 4000 | ||
before( function(done) { | ||
this.timeout(10000) | ||
goOutput = exec('../mobile-developer-console') | ||
goOutput.stdout.on('data', data => { | ||
console.log(data.toString()) | ||
}) | ||
goOutput.stderr.on('data', data => { | ||
const message = data.toString() | ||
console.log(message) | ||
if (message.indexOf("Starting application") > -1) { | ||
done() | ||
} | ||
}) | ||
}); | ||
|
||
after(() => { | ||
goOutput.kill("SIGINT") | ||
}) | ||
|
||
describe('Mobile Clients', () => { | ||
require('./mobile_clients') | ||
}); |
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,18 @@ | ||
const axios = require('axios') | ||
|
||
const api = "http://localhost:4000/api" | ||
|
||
const sendRequest = async (method, path, data) => { | ||
let headers | ||
if (method === "POST") { | ||
headers = {'Content-Type': 'application/json'} | ||
} | ||
return await axios({ | ||
url: `${api}/${path}`, | ||
method, | ||
data, | ||
headers | ||
}) | ||
} | ||
|
||
module.exports = sendRequest |