chore(api): update deps/tests
This commit is contained in:
parent
983db9ede5
commit
0d8a282248
@ -21,7 +21,7 @@
|
||||
"joi": "^10.6.0",
|
||||
"joyent-cp-gql-schema": "^1.5.2",
|
||||
"piloted": "^3.1.1",
|
||||
"portal-api": "^1.4.1",
|
||||
"portal-api": "^1.5.0",
|
||||
"toppsy": "^1.1.0",
|
||||
"triton": "^5.2.0"
|
||||
}
|
||||
|
@ -152,7 +152,10 @@ class Data extends EventEmitter {
|
||||
reconnectDb (db) {
|
||||
this._settings.db = db;
|
||||
|
||||
this._db.close();
|
||||
try {
|
||||
this._db.close();
|
||||
} catch (ex) {}
|
||||
|
||||
this._db = new Penseur.Db(this._settings.name, this._settings.db);
|
||||
|
||||
this.connect((err) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "portal-api",
|
||||
"version": "1.4.1",
|
||||
"version": "1.5.0",
|
||||
"description": "",
|
||||
"main": "./lib/index.js",
|
||||
"scripts": {
|
||||
@ -21,7 +21,7 @@
|
||||
"author": "wyatt",
|
||||
"license": "MPL-2.0",
|
||||
"devDependencies": {
|
||||
"belly-button": "^3.1.0",
|
||||
"belly-button": "^4.0.1",
|
||||
"brule": "^2.0.0",
|
||||
"good": "^7.2.0",
|
||||
"good-console": "^6.4.0",
|
||||
@ -37,7 +37,7 @@
|
||||
"docker-compose-client": "^1.0.8",
|
||||
"dockerode": "^2.5.0",
|
||||
"force-array": "^3.1.0",
|
||||
"graphi": "^2.2.1",
|
||||
"graphi": "^3.0.0",
|
||||
"hoek": "^4.1.1",
|
||||
"joyent-cp-gql-schema": "^1.6.0",
|
||||
"lodash.find": "^4.6.0",
|
||||
@ -54,6 +54,6 @@
|
||||
"triton": "^5.3.1",
|
||||
"triton-watch": "^1.1.0",
|
||||
"uuid": "^3.1.0",
|
||||
"vasync": "^1.6.4"
|
||||
"vasync": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ consul:
|
||||
-ui-dir /ui
|
||||
restart: always
|
||||
mem_limit: 128m
|
||||
ports:
|
||||
- 8500:8500
|
||||
expose:
|
||||
- 8500
|
||||
dns:
|
||||
- 127.0.0.1
|
||||
- 127.0.0.1
|
||||
compose-api:
|
||||
image: joyent/copilot-compose
|
||||
links:
|
||||
@ -33,10 +33,10 @@ rethinkdb:
|
||||
environment:
|
||||
- CONSUL=consul
|
||||
- CONSUL_AGENT=1
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 28015:28015
|
||||
- 29015:29015
|
||||
expose:
|
||||
- 8080
|
||||
- 28015
|
||||
- 29015
|
||||
dns:
|
||||
- 127.0.0.1
|
||||
api:
|
||||
@ -50,7 +50,5 @@ api:
|
||||
- ../../_env
|
||||
environment:
|
||||
- CONSUL=consul
|
||||
expose:
|
||||
- 9090
|
||||
dns:
|
||||
- 127.0.0.1
|
||||
- 127.0.0.1
|
||||
|
@ -3,11 +3,15 @@
|
||||
jobs: [
|
||||
{
|
||||
name: 'setup-config',
|
||||
exec: '/bin/prestart.sh'
|
||||
exec: '/bin/prestart.sh',
|
||||
when: {
|
||||
source: 'watch.rethinkdb',
|
||||
once: 'healthy'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'tests',
|
||||
exec: 'node node_modules/.bin/lab -c',
|
||||
exec: 'node node_modules/.bin/lab -c -m 10000',
|
||||
when: {
|
||||
source: 'setup-config',
|
||||
once: 'exitSuccess'
|
||||
@ -23,10 +27,5 @@
|
||||
name: 'docker-compose-api',
|
||||
interval: 5
|
||||
}
|
||||
],
|
||||
telemetry: {
|
||||
port: 9090,
|
||||
tags: ['op'],
|
||||
metrics: []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -3,17 +3,14 @@
|
||||
const Fs = require('fs');
|
||||
const Path = require('path');
|
||||
const { describe, it, beforeEach, expect } = exports.lab = require('lab').script();
|
||||
const Piloted = require('piloted');
|
||||
const PortalData = require('../../lib/data');
|
||||
|
||||
|
||||
const rethinkdb = Piloted.service('rethinkdb');
|
||||
const internals = {
|
||||
options: {
|
||||
name: 'test',
|
||||
db: {
|
||||
test: true,
|
||||
host: rethinkdb ? rethinkdb.address : 'rethinkdb'
|
||||
host: 'rethinkdb'
|
||||
},
|
||||
server: {
|
||||
log: function () {}
|
||||
@ -28,21 +25,14 @@ beforeEach((done) => {
|
||||
data.connect((err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
data._db.r.dbDrop('test').run(data._db._connection, () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('connect()', () => {
|
||||
it('connects to the database', (done) => {
|
||||
const data = new PortalData(internals.options);
|
||||
data.connect(done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('portals', () => {
|
||||
describe('getPortal()', () => {
|
||||
it('retrieves a single portal record', (done) => {
|
||||
@ -124,7 +114,7 @@ describe('deployment groups', () => {
|
||||
data.createDeploymentGroup({ name }, (err, createdDeploymentGroup1) => {
|
||||
expect(err).to.not.exist();
|
||||
expect(createdDeploymentGroup1.id).to.exist();
|
||||
data.createDeploymentGroup({ name }, (err, createdDeploymentGroup2) => {
|
||||
data.createDeploymentGroup({ name: 'User Services 2' }, (err, createdDeploymentGroup2) => {
|
||||
expect(err).to.not.exist();
|
||||
expect(createdDeploymentGroup1.id).to.exist();
|
||||
|
||||
@ -133,7 +123,6 @@ describe('deployment groups', () => {
|
||||
expect(deploymentGroups.length).to.be.greaterThan(1);
|
||||
data.getDeploymentGroups({ name }, (err, deploymentGroups) => {
|
||||
expect(err).to.not.exist();
|
||||
expect(deploymentGroups.length).to.be.greaterThan(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ const internals = {
|
||||
options: {
|
||||
data: {
|
||||
name: 'test',
|
||||
db: { test: true },
|
||||
db: { test: true, host: 'rethinkdb' },
|
||||
server: {
|
||||
log: function () { }
|
||||
}
|
||||
@ -31,7 +31,6 @@ describe('portal-api plugin', () => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('graphql', () => {
|
||||
it('route exists', (done) => {
|
||||
const server = new Hapi.Server();
|
||||
@ -42,8 +41,7 @@ describe('graphql', () => {
|
||||
|
||||
server.inject({ method: 'GET', url }, (res) => {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
const result = JSON.parse(res.result);
|
||||
expect(result.data).to.exist();
|
||||
expect(res.result.data).to.exist();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -61,9 +59,8 @@ describe('graphql', () => {
|
||||
|
||||
server.inject({ method: 'POST', url: '/graphql', payload }, (res) => {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
const result = JSON.parse(res.result);
|
||||
expect(result.data).to.exist();
|
||||
expect(result.data.portal.deploymentGroups[0].name).to.equal('test1');
|
||||
expect(res.result.data).to.exist();
|
||||
expect(res.result.data.portal.deploymentGroups[0].name).to.equal('test1');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -81,9 +78,8 @@ describe('graphql', () => {
|
||||
|
||||
server.inject({ method: 'POST', url: '/graphql', payload }, (res) => {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
const result = JSON.parse(res.result);
|
||||
expect(result.data).to.exist();
|
||||
expect(result.data.portal.deploymentGroups.length).to.equal(2);
|
||||
expect(res.result.data).to.exist();
|
||||
expect(res.result.data.portal.deploymentGroups.length).to.equal(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -96,15 +92,14 @@ describe('graphql', () => {
|
||||
expect(err).to.not.exist();
|
||||
|
||||
const payload = {
|
||||
query: '{ portal { datacenter { region }, deploymentGroups(name: "test2") { name, services(name: "service") { name } } } }'
|
||||
query: '{ portal { datacenter { region }, deploymentGroups(name: "test") { name, services(name: "service") { name } } } }'
|
||||
};
|
||||
|
||||
server.inject({ method: 'POST', url: '/graphql', payload }, (res) => {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
const result = JSON.parse(res.result);
|
||||
const deploymentGroup = result.data.portal.deploymentGroups[0];
|
||||
|
||||
expect(deploymentGroup.name).to.equal('test2');
|
||||
console.log(res.result.data)
|
||||
const deploymentGroup = res.result.data.portal.deploymentGroups[0];
|
||||
expect(deploymentGroup.name).to.equal('test');
|
||||
expect(deploymentGroup.services[0].name).to.equal('service');
|
||||
done();
|
||||
});
|
||||
|
@ -29,4 +29,4 @@ IS_RETHINK_DOWN=1
|
||||
until [ $IS_RETHINK_DOWN -eq 0 ]; do
|
||||
curl -o /dev/null --fail -s -m 10 http://rethinkdb:8080
|
||||
IS_RETHINK_DOWN=$(echo $?)
|
||||
done
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user