From 57ce3380e6085a648c9eb009900fbf360ed5ac01 Mon Sep 17 00:00:00 2001 From: Gabriel Oliveira Date: Tue, 3 Jan 2017 10:38:03 -0200 Subject: [PATCH] version 1.0.0 --- .babelrc | 9 + .editorconfig | 2 +- .gitignore | 1 + .jshintrc | 9 + README.md | 69 ++++++- package.json | 43 +++++ src/env.json | 4 + src/track.js | 33 ++++ tests/e2e/track.spec.js | 87 +++++++++ tests/responses/valid-one.json | 101 ++++++++++ tests/responses/valid-two.json | 199 ++++++++++++++++++++ tests/unit/fixtures/response-valid-one.xml | 110 +++++++++++ tests/unit/fixtures/response-valid-two.xml | 206 +++++++++++++++++++++ tests/unit/track.spec.js | 96 ++++++++++ 14 files changed, 967 insertions(+), 2 deletions(-) create mode 100644 .babelrc create mode 100644 .jshintrc create mode 100644 package.json create mode 100644 src/env.json create mode 100644 src/track.js create mode 100644 tests/e2e/track.spec.js create mode 100644 tests/responses/valid-one.json create mode 100644 tests/responses/valid-two.json create mode 100644 tests/unit/fixtures/response-valid-one.xml create mode 100644 tests/unit/fixtures/response-valid-two.xml create mode 100644 tests/unit/track.spec.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..be9981d --- /dev/null +++ b/.babelrc @@ -0,0 +1,9 @@ +{ + "presets": ["es2015"], + "plugins": ["babel-plugin-add-module-exports"], + "env": { + "production": { + "presets": ["babili"] + } + } +} diff --git a/.editorconfig b/.editorconfig index 1ac097a..5d4354e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,6 +8,6 @@ indent_size = 4 trim_trailing_whitespace = true charset = utf-8 -[*.json] +[{*.json,.babelrc,.jshintrc}] indent_style = space indent_size = 2 diff --git a/.gitignore b/.gitignore index cebebc2..afad90e 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ jspm_packages # Build files dist +prod diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..901b593 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,9 @@ +{ + "node": true, + "mocha": true, + "esversion": 6, + "globalstrict": false, + "asi": true, + "curly": true, + "trailing": true +} diff --git a/README.md b/README.md index e941031..0d8326f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,70 @@ # rest-tracking -REST developed for [tracking-correios](https://github.com/gabrielboliveira/tracking-correios) package. +API REST para abstrair o método `track` do pacote [tracking-correios](https://github.com/gabrielboliveira/tracking-correios). + +## Pré-requisitos + +- Node.js (versão 0.12 a latest) +- npm + +## Instalação + +```sh +# ssh +$ git clone git@github.com:gabrielboliveira/rest-tracking.git + +# https +$ git clone https://github.com/gabrielboliveira/rest-tracking.git + +$ cd rest-tracking +$ npm install +$ node start +``` + +A configuração da porta padrão (3000) é feita no arquivo [env.json](src/env.json). + +## Uso + +A API expõe o endpoint `/track` para obter os dados de rastreio dos pacotes. Recebe um objeto com atributo `codes` e um array de códigos: + +```json +{ + "codes": ["DU123123123BR"] +} +``` + +Exemplo: + +```sh +$ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"codes": ["DU123123123BR"]}' http://localhost:3000/track + +> HTTP/1.1 200 OK +Content-Type: application/json +Content-Length: 101 +Date: Tue, 03 Jan 2017 12:29:09 GMT +Connection: keep-alive + +{"data":[{"numero":"DU123123123BR","erro":"Objeto não encontrado na base de dados dos Correios."}]} +``` + +## Produção + +Para executar a API em produção é recomendado um _process manager_ como por exemplo [PM2](https://github.com/Unitech/pm2) ou [forever](https://github.com/foreverjs/forever). + +```sh' +$ npm run build-prod +$ pm2 start prod/track.js --name="rest-tracking" +``` + +## Testes + +Para desenvolvimento, foram desenvolvidos testes unitários e E2E. Para executá-los, deve rodar o seguinte script: + +```sh +$ npm test +``` + +## Licença + +[MIT](LICENSE.md). + diff --git a/package.json b/package.json new file mode 100644 index 0000000..1392570 --- /dev/null +++ b/package.json @@ -0,0 +1,43 @@ +{ + "name": "rest-tracking", + "version": "1.0.0", + "description": "REST desenvolvido para abstrair o pacote tracking-correios.", + "main": "dist/track.js", + "keywords": [], + "author": "Gabriel Oliveira", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/gabrielboliveira/rest-tracking.git" + }, + "bugs": { + "url": "https://github.com/gabrielboliveira/rest-tracking/issues" + }, + "scripts": { + "test": "npm run test-unit && npm run test-e2e", + "test-e2e": "mocha --compilers js:babel-core/register tests/e2e/*.spec.js --timeout 15000", + "test-unit": "mocha --compilers js:babel-core/register tests/unit/*.spec.js", + "build": "babel src --out-dir dist --copy-files", + "build-prod": "BABEL_ENV=production babel src --out-dir prod --copy-files", + "postinstall": "npm run build", + "start": "node dist/track.js", + "prod": "node prod/track.js" + }, + "dependencies": { + "restify": "^4.3.0", + "tracking-correios": "^1.0.4" + }, + "devDependencies": { + "babel-cli": "^6.18.0", + "babel-core": "^6.20.0", + "babel-plugin-add-module-exports": "^0.2.1", + "babel-preset-es2015": "^6.18.0", + "babili": "0.0.9", + "chai": "^3.5.0", + "chai-as-promised": "^6.0.0", + "chai-http": "^3.0.0", + "chai-subset": "^1.3.0", + "mocha": "^3.2.0", + "nock": "^9.0.2" + } +} diff --git a/src/env.json b/src/env.json new file mode 100644 index 0000000..80f61e3 --- /dev/null +++ b/src/env.json @@ -0,0 +1,4 @@ +{ + "name": "REST Tracking", + "port": 3000 +} diff --git a/src/track.js b/src/track.js new file mode 100644 index 0000000..70d19a0 --- /dev/null +++ b/src/track.js @@ -0,0 +1,33 @@ +const restify = require('restify') +const TrackingCorreios = require('tracking-correios') +const env = require('./env') + +const server = restify.createServer({ + name: env.name +}) + +server.use(restify.bodyParser()) + +server.post('/track', (req, res, next) => { + if (req && req.params && req.params.codes) { + TrackingCorreios.track(req.params.codes) + .then( success => { + res.send( { data: success } ) + }) + .catch( error => { + res.send(new restify.InvalidArgumentError(error.message)) + }) + .finally( () => { + next() + }) + } else { + res.send(new restify.InvalidArgumentError("Nenhum dado válido recebido.")) + next() + } +}); + +server.listen(env.port, () => console.log(`${server.name} listening at ${server.url}`)) + +process.on('uncaughtException', function (err) { + console.error(JSON.parse(JSON.stringify(err, ['stack', 'message', 'inner'], 2))) +}) diff --git a/tests/e2e/track.spec.js b/tests/e2e/track.spec.js new file mode 100644 index 0000000..de62a52 --- /dev/null +++ b/tests/e2e/track.spec.js @@ -0,0 +1,87 @@ +"use strict" + +const chai = require('chai') +const chaiHttp = require('chai-http') +const server = require('../../src/track') +const { port } = require('../../src/env') + +const path = require('path') + +chai.use(chaiHttp) + +const expect = chai.expect; + +describe('rest-tracking (unit)', () => { + + describe('/POST', () => { + let testFileOne = require('../responses/valid-one.json') + let testFileTwo = require('../responses/valid-two.json') + let postObj = { + "codes": [ ] + } + + it('it should POST with valid code', (done) => { + postObj.codes = [ "DU897123996BR" ] + + chai.request(`localhost:${port}`) + .post('/track') + .send(postObj) + .end((err, res) => { + expect(err).to.be.null; + expect(res).to.have.status(200); + expect(res).to.be.a('object'); + expect(res.body).to.have.property('data'); + expect(res.body.data).to.be.deep.equal(testFileOne); + done(); + }); + }); + + it('it should POST with several valid code', (done) => { + postObj.codes = [ 'DU897123996BR', 'PN273603577BR' ] + + chai.request(`localhost:${port}`) + .post('/track') + .send(postObj) + .end((err, res) => { + expect(err).to.be.null; + expect(res).to.have.status(200); + expect(res).to.be.a('object'); + expect(res.body).to.have.property('data'); + expect(res.body.data).to.be.deep.equal(testFileTwo); + done(); + }); + }); + + it('it should POST with invalid code', (done) => { + postObj.codes = [ "invalid" ] + + chai.request(`localhost:${port}`) + .post('/track') + .send(postObj) + .end((err, res) => { + expect(err).to.not.be.null; + expect(res).to.have.status(409); + expect(res).to.be.a('object'); + expect(res.body).to.have.property('code'); + expect(res.body).to.have.property('message'); + done(); + }); + }); + + it('it should POST with nothing', (done) => { + chai.request(`localhost:${port}`) + .post('/track') + .send('') + .end((err, res) => { + expect(err).to.not.be.null; + expect(res).to.have.status(409); + expect(res).to.be.a('object'); + expect(res.body).to.have.property('code'); + expect(res.body).to.have.property('message'); + done(); + }); + }); + + }); + +}) diff --git a/tests/responses/valid-one.json b/tests/responses/valid-one.json new file mode 100644 index 0000000..76ff831 --- /dev/null +++ b/tests/responses/valid-one.json @@ -0,0 +1,101 @@ +[ + { + "numero": "DU897123996BR", + "sigla": "DU", + "nome": "ENCOMENDA E-SEDEX", + "categoria": "E-SEDEX", + "evento": [ + { + "tipo": "BDE", + "status": "01", + "data": "12/12/2016", + "hora": "19:06", + "descricao": "Objeto entregue ao destinatário", + "recebedor": "", + "documento": "", + "comentario": "", + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "uf": "SP" + }, + { + "tipo": "OEC", + "status": "01", + "data": "12/12/2016", + "hora": "10:30", + "descricao": "Objeto saiu para entrega ao destinatário", + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "uf": "SP" + }, + { + "tipo": "RO", + "status": "01", + "data": "12/12/2016", + "hora": "04:34", + "descricao": "Objeto encaminhado", + "local": "CTCE BAURU", + "codigo": "17034970", + "cidade": "Bauru", + "uf": "SP", + "destino": { + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "bairro": "Distrito Industrial", + "uf": "SP" + } + }, + { + "tipo": "RO", + "status": "01", + "data": "08/12/2016", + "hora": "21:13", + "descricao": "Objeto encaminhado", + "local": "CTCE LONDRINA", + "codigo": "86066970", + "cidade": "LONDRINA", + "uf": "PR", + "destino": { + "local": "CTCE BAURU", + "codigo": "17034970", + "cidade": "Bauru", + "bairro": "Distrito Industrial", + "uf": "SP" + } + }, + { + "tipo": "RO", + "status": "01", + "data": "08/12/2016", + "hora": "13:37", + "descricao": "Objeto encaminhado", + "local": "AGF JARDIM ALVORADA", + "codigo": "87030981", + "cidade": "Maringa", + "uf": "PR", + "destino": { + "local": "CTCE LONDRINA", + "codigo": "86066970", + "cidade": "LONDRINA", + "bairro": "JARDIM COLUMBIA", + "uf": "PR" + } + }, + { + "tipo": "PO", + "status": "09", + "data": "07/12/2016", + "hora": "17:37", + "descricao": "Objeto postado após o horário limite da agência", + "detalhe": "Objeto sujeito a encaminhamento no próximo dia útil", + "local": "AGF JARDIM ALVORADA", + "codigo": "87030981", + "cidade": "Maringa", + "uf": "PR" + } + ] + } +] diff --git a/tests/responses/valid-two.json b/tests/responses/valid-two.json new file mode 100644 index 0000000..e3be8f3 --- /dev/null +++ b/tests/responses/valid-two.json @@ -0,0 +1,199 @@ +[ + { + "numero": "DU897123996BR", + "sigla": "DU", + "nome": "ENCOMENDA E-SEDEX", + "categoria": "E-SEDEX", + "evento": [ + { + "tipo": "BDE", + "status": "01", + "data": "12/12/2016", + "hora": "19:06", + "descricao": "Objeto entregue ao destinatário", + "recebedor": "", + "documento": "", + "comentario": "", + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "uf": "SP" + }, + { + "tipo": "OEC", + "status": "01", + "data": "12/12/2016", + "hora": "10:30", + "descricao": "Objeto saiu para entrega ao destinatário", + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "uf": "SP" + }, + { + "tipo": "RO", + "status": "01", + "data": "12/12/2016", + "hora": "04:34", + "descricao": "Objeto encaminhado", + "local": "CTCE BAURU", + "codigo": "17034970", + "cidade": "Bauru", + "uf": "SP", + "destino": { + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "bairro": "Distrito Industrial", + "uf": "SP" + } + }, + { + "tipo": "RO", + "status": "01", + "data": "08/12/2016", + "hora": "21:13", + "descricao": "Objeto encaminhado", + "local": "CTCE LONDRINA", + "codigo": "86066970", + "cidade": "LONDRINA", + "uf": "PR", + "destino": { + "local": "CTCE BAURU", + "codigo": "17034970", + "cidade": "Bauru", + "bairro": "Distrito Industrial", + "uf": "SP" + } + }, + { + "tipo": "RO", + "status": "01", + "data": "08/12/2016", + "hora": "13:37", + "descricao": "Objeto encaminhado", + "local": "AGF JARDIM ALVORADA", + "codigo": "87030981", + "cidade": "Maringa", + "uf": "PR", + "destino": { + "local": "CTCE LONDRINA", + "codigo": "86066970", + "cidade": "LONDRINA", + "bairro": "JARDIM COLUMBIA", + "uf": "PR" + } + }, + { + "tipo": "PO", + "status": "09", + "data": "07/12/2016", + "hora": "17:37", + "descricao": "Objeto postado após o horário limite da agência", + "detalhe": "Objeto sujeito a encaminhamento no próximo dia útil", + "local": "AGF JARDIM ALVORADA", + "codigo": "87030981", + "cidade": "Maringa", + "uf": "PR" + } + ] + }, + { + "numero": "PN273603577BR", + "sigla": "PN", + "nome": "ENCOMENDA PAC (ETIQ LOGICA)", + "categoria": "ENCOMENDA PAC", + "evento": [ + { + "tipo": "BDE", + "status": "01", + "data": "28/10/2016", + "hora": "18:24", + "descricao": "Objeto entregue ao destinatário", + "recebedor": "", + "documento": "", + "comentario": "", + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "uf": "SP" + }, + { + "tipo": "OEC", + "status": "01", + "data": "28/10/2016", + "hora": "11:29", + "descricao": "Objeto saiu para entrega ao destinatário", + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "uf": "SP" + }, + { + "tipo": "RO", + "status": "01", + "data": "27/10/2016", + "hora": "13:02", + "descricao": "Objeto encaminhado", + "local": "CTCE BAURU", + "codigo": "17034970", + "cidade": "Bauru", + "uf": "SP", + "destino": { + "local": "CEE BAURU", + "codigo": "17034972", + "cidade": "Bauru", + "bairro": "Distrito Industrial", + "uf": "SP" + } + }, + { + "tipo": "DO", + "status": "01", + "data": "26/10/2016", + "hora": "19:08", + "descricao": "Objeto encaminhado", + "local": "AGF OZANAN", + "codigo": "13215971", + "cidade": "Jundiai", + "uf": "SP", + "destino": { + "local": "CTE CAMPINAS", + "codigo": "13050971", + "cidade": "INDAIATUBA", + "bairro": "HELVETIA", + "uf": "SP" + } + }, + { + "tipo": "RO", + "status": "01", + "data": "26/10/2016", + "hora": "14:34", + "descricao": "Objeto encaminhado", + "local": "CTE CAMPINAS", + "codigo": "13050971", + "cidade": "INDAIATUBA", + "uf": "SP", + "destino": { + "local": "CTCE BAURU", + "codigo": "17034970", + "cidade": "Bauru", + "bairro": "Distrito Industrial", + "uf": "SP" + } + }, + { + "tipo": "PO", + "status": "01", + "data": "25/10/2016", + "hora": "16:35", + "descricao": "Objeto postado", + "local": "AGF OZANAN", + "codigo": "13215971", + "cidade": "Jundiai", + "uf": "SP" + } + ] + } +] diff --git a/tests/unit/fixtures/response-valid-one.xml b/tests/unit/fixtures/response-valid-one.xml new file mode 100644 index 0000000..2deffa1 --- /dev/null +++ b/tests/unit/fixtures/response-valid-one.xml @@ -0,0 +1,110 @@ + + + pid=36263,requestid=2cb01ac165f9c688f949b4a985e0531286a43f3af2e7fbe9 + + + + + 2.0 + 1 + + DU897123996BR + DU + ENCOMENDA E-SEDEX + E-SEDEX + + BDE + 01 + 12/12/2016 + 19:06 + Objeto entregue ao destinatário + + + + CEE BAURU + 17034972 + Bauru + SP + + + OEC + 01 + 12/12/2016 + 10:30 + Objeto saiu para entrega ao destinatário + CEE BAURU + 17034972 + Bauru + SP + + + RO + 01 + 12/12/2016 + 04:34 + Objeto encaminhado + CTCE BAURU + 17034970 + Bauru + SP + + CEE BAURU + 17034972 + Bauru + Distrito Industrial + SP + + + + RO + 01 + 08/12/2016 + 21:13 + Objeto encaminhado + CTCE LONDRINA + 86066970 + LONDRINA + PR + + CTCE BAURU + 17034970 + Bauru + Distrito Industrial + SP + + + + RO + 01 + 08/12/2016 + 13:37 + Objeto encaminhado + AGF JARDIM ALVORADA + 87030981 + Maringa + PR + + CTCE LONDRINA + 86066970 + LONDRINA + JARDIM COLUMBIA + PR + + + + PO + 09 + 07/12/2016 + 17:37 + Objeto postado após o horário limite da agência + Objeto sujeito a encaminhamento no próximo dia útil + AGF JARDIM ALVORADA + 87030981 + Maringa + PR + + + + + + diff --git a/tests/unit/fixtures/response-valid-two.xml b/tests/unit/fixtures/response-valid-two.xml new file mode 100644 index 0000000..8f18a28 --- /dev/null +++ b/tests/unit/fixtures/response-valid-two.xml @@ -0,0 +1,206 @@ + + + pid=130635,requestid=abd12a3d40122ab62b34d9e70d5c29eecbe835bf7b91d67e + + + + + 2.0 + 2 + + DU897123996BR + DU + ENCOMENDA E-SEDEX + E-SEDEX + + BDE + 01 + 12/12/2016 + 19:06 + Objeto entregue ao destinatário + + + + CEE BAURU + 17034972 + Bauru + SP + + + OEC + 01 + 12/12/2016 + 10:30 + Objeto saiu para entrega ao destinatário + CEE BAURU + 17034972 + Bauru + SP + + + RO + 01 + 12/12/2016 + 04:34 + Objeto encaminhado + CTCE BAURU + 17034970 + Bauru + SP + + CEE BAURU + 17034972 + Bauru + Distrito Industrial + SP + + + + RO + 01 + 08/12/2016 + 21:13 + Objeto encaminhado + CTCE LONDRINA + 86066970 + LONDRINA + PR + + CTCE BAURU + 17034970 + Bauru + Distrito Industrial + SP + + + + RO + 01 + 08/12/2016 + 13:37 + Objeto encaminhado + AGF JARDIM ALVORADA + 87030981 + Maringa + PR + + CTCE LONDRINA + 86066970 + LONDRINA + JARDIM COLUMBIA + PR + + + + PO + 09 + 07/12/2016 + 17:37 + Objeto postado após o horário limite da agência + Objeto sujeito a encaminhamento no próximo dia útil + AGF JARDIM ALVORADA + 87030981 + Maringa + PR + + + + PN273603577BR + PN + ENCOMENDA PAC (ETIQ LOGICA) + ENCOMENDA PAC + + BDE + 01 + 28/10/2016 + 18:24 + Objeto entregue ao destinatário + + + + CEE BAURU + 17034972 + Bauru + SP + + + OEC + 01 + 28/10/2016 + 11:29 + Objeto saiu para entrega ao destinatário + CEE BAURU + 17034972 + Bauru + SP + + + RO + 01 + 27/10/2016 + 13:02 + Objeto encaminhado + CTCE BAURU + 17034970 + Bauru + SP + + CEE BAURU + 17034972 + Bauru + Distrito Industrial + SP + + + + DO + 01 + 26/10/2016 + 19:08 + Objeto encaminhado + AGF OZANAN + 13215971 + Jundiai + SP + + CTE CAMPINAS + 13050971 + INDAIATUBA + HELVETIA + SP + + + + RO + 01 + 26/10/2016 + 14:34 + Objeto encaminhado + CTE CAMPINAS + 13050971 + INDAIATUBA + SP + + CTCE BAURU + 17034970 + Bauru + Distrito Industrial + SP + + + + PO + 01 + 25/10/2016 + 16:35 + Objeto postado + AGF OZANAN + 13215971 + Jundiai + SP + + + + + + diff --git a/tests/unit/track.spec.js b/tests/unit/track.spec.js new file mode 100644 index 0000000..7733d4b --- /dev/null +++ b/tests/unit/track.spec.js @@ -0,0 +1,96 @@ +"use strict" + +const chai = require('chai') +const chaiHttp = require('chai-http') +const server = require('../../src/track') +const { port } = require('../../src/env') + +const nock = require('nock') +const path = require('path') + +chai.use(chaiHttp) + +const expect = chai.expect; + +describe('rest-tracking (unit)', () => { + + describe('/POST', () => { + let testFileOne = require('../responses/valid-one.json') + let testFileTwo = require('../responses/valid-two.json') + let postObj = { + "codes": [ ] + } + + it('it should POST with valid code', (done) => { + postObj.codes = [ "DU897123996BR" ] + + nock('https://webservice.correios.com.br') + .post('/service/rastro') + .replyWithFile(200, path.join(__dirname, '/fixtures/response-valid-one.xml')) + + chai.request(`localhost:${port}`) + .post('/track') + .send(postObj) + .end((err, res) => { + expect(err).to.be.null; + expect(res).to.have.status(200); + expect(res).to.be.a('object'); + expect(res.body).to.have.property('data'); + expect(res.body.data).to.be.deep.equal(testFileOne); + done(); + }); + }); + + it('it should POST with several valid code', (done) => { + postObj.codes = [ 'DU897123996BR', 'PN273603577BR' ] + + nock('https://webservice.correios.com.br') + .post('/service/rastro') + .replyWithFile(200, path.join(__dirname, '/fixtures/response-valid-two.xml')) + + chai.request(`localhost:${port}`) + .post('/track') + .send(postObj) + .end((err, res) => { + expect(err).to.be.null; + expect(res).to.have.status(200); + expect(res).to.be.a('object'); + expect(res.body).to.have.property('data'); + expect(res.body.data).to.be.deep.equal(testFileTwo); + done(); + }); + }); + + it('it should POST with invalid code', (done) => { + postObj.codes = [ "invalid" ] + + chai.request(`localhost:${port}`) + .post('/track') + .send(postObj) + .end((err, res) => { + expect(err).to.not.be.null; + expect(res).to.have.status(409); + expect(res).to.be.a('object'); + expect(res.body).to.have.property('code'); + expect(res.body).to.have.property('message'); + done(); + }); + }); + + it('it should POST with nothing', (done) => { + chai.request(`localhost:${port}`) + .post('/track') + .send('') + .end((err, res) => { + expect(err).to.not.be.null; + expect(res).to.have.status(409); + expect(res).to.be.a('object'); + expect(res.body).to.have.property('code'); + expect(res.body).to.have.property('message'); + done(); + }); + }); + + }); + +})