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