Skip to content

Commit 517c2ed

Browse files
committed
Merge pull request #12 from RioBus/dev
Fixing test workflow
2 parents 8bcd059 + 45f811c commit 517c2ed

File tree

7 files changed

+33
-46
lines changed

7 files changed

+33
-46
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ Execute a aplicação:
3939
4040
Os dados dos ônibus são salvos no banco de dados NoSQL [MongoDB](https://www.mongodb.org/). Certifique-se de que ele
4141
esteja ligado antes de executar a aplicação. As configurações de conexão devem ser definidas nas variáveis de ambiente do
42-
Sistema Operacional de acordo com as configurações padrão descritas em ```env.config.sh```.
42+
Sistema Operacional de acordo com o modelo:
43+
44+
> RIOBUS_DB_NAME - Nome do banco
45+
> RIOBUS_DB_HOST - Endereço do SGBD
46+
> RIOBUS_DB_PORT - Porta do banco
47+
> RIOBUS_DB_USER - Usuário do banco
48+
> RIOBUS_DB_PASS - Senha de acesso ao banco
4349
4450
Comandos NPM
4551
------------
@@ -51,9 +57,9 @@ npm start
5157
> Roda a aplicação
5258
5359
npm install
54-
> Inslata as dependências locais e globais do projeto.
60+
> Inslata as dependências do projeto.
5561
5662
Compatibilidade
5763
---------------
5864

59-
* node.js >= 0.11
65+
* node.js >= 4.0.0

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"description": "RioBus data-provider application",
55
"main": "src/app.js",
66
"scripts": {
7-
"test": "mocha test/**/* --timeout 5000",
8-
"start": "node src/app.js"
7+
"test": "mocha test/* test/**/* --timeout 20000",
8+
"start": "node src/app.js",
9+
"install": "npm install -g mocha-co"
910
},
1011
"compiler": "commonjs",
1112
"repository": {
@@ -41,7 +42,6 @@
4142
"robe": "^0.12.0"
4243
},
4344
"devDependencies": {
44-
"mocha": "^2.2.5",
45-
"co-mocha": "^1.1.2"
45+
"mocha-co": "^1.17.1-co.1"
4646
}
4747
}

test/dao/busDAO.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
/* global describe, it, before, global, __dirname, after; */
3-
require('co-mocha')(require('mocha'));
43
const base = `${__dirname}/../../src`;
54

65
const Assert = require('assert');
@@ -19,7 +18,7 @@ describe('BusDAO', () => {
1918
dao = new BusDAO(conn);
2019
});
2120

22-
it('should insert data', function*(done) {
21+
it('should insert data', function*() {
2322
let data = new Bus('line', 'order', 0, 0, 23, 45, (new Date()).toDateString(), 'sense');
2423
const common = yield dao.commonSave(data);
2524
const history = yield dao.historySave(data);
@@ -45,7 +44,6 @@ describe('BusDAO', () => {
4544
Assert.notEqual(common._id, undefined);
4645
Assert.notEqual(history._id, undefined);
4746
saved = [ common, history ];
48-
done();
4947
});
5048

5149
after(function*() {

test/dao/itineraryDAO.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
/* global describe, it, before, global, __dirname, after; */
3-
require('co-mocha')(require('mocha'));
43
const base = `${__dirname}/../../src`;
54

65
const Assert = require('assert');
@@ -18,7 +17,7 @@ describe('ItineraryDAO', () => {
1817
dao = new ItineraryDAO(conn);
1918
});
2019

21-
it('should insert data', function*(done) {
20+
it('should insert data', function*() {
2221
let data = new Itinerary('line', 'description', 'agency', 'keywords');
2322
const response = yield dao.save(data);
2423
Assert.equal(response.line, data.line);
@@ -27,13 +26,11 @@ describe('ItineraryDAO', () => {
2726
Assert.equal(response.keywords, data.keywords);
2827
Assert.notEqual(response._id, undefined);
2928
saved = response;
30-
done();
3129
});
3230

33-
it('should retrieve the recently inserted data', function*(done) {
31+
it('should retrieve the recently inserted data', function*() {
3432
const response = yield dao.getAll();
3533
Assert.equal(response.length, 1);
36-
done();
3734
});
3835

3936
after(function*() {

test/database.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,45 @@
11
'use strict';
22
/* global describe, it, before; */
3-
require('co-mocha')(require('mocha'));
43

54
const Assert = require('assert');
65
const Database = require('../src/core').Database;
76

8-
var db, collection;
9-
107
describe('Database', () => {
118

12-
it('should connect to database', function*(done) {
9+
var db, collection;
10+
11+
it('should connect to database', function*() {
1312
db = yield Database.connect();
1413
Assert.notEqual(db, null);
15-
done();
1614
});
1715

18-
it('should access the collection test', function*(done) {
16+
it('should access the collection test', function*() {
1917
collection = db.collection('test');
2018
Assert.notEqual(collection, null);
21-
done();
2219
});
2320

24-
it('should insert data in the collection', function*(done) {
21+
it('should insert data in the collection', function*() {
2522
yield collection.insert({ name: 'Fulano' });
2623

2724
var item = yield collection.findOne({ name: 'Fulano' });
2825
Assert.equal(item.name, 'Fulano');
29-
done();
3026
});
3127

32-
it('should update Fulano in the collection', function*(done) {
28+
it('should update Fulano in the collection', function*() {
3329
var item = yield collection.findOne({ name: 'Fulano' });
3430
item.name = 'Ciclano';
3531
yield item.save();
3632
Assert.equal(item.name, 'Ciclano');
37-
done();
3833
});
3934

40-
it('should retrieve all documents in test collection', function*(done) {
35+
it('should retrieve all documents in test collection', function*() {
4136
var items = yield collection.find({});
4237
Assert.notEqual(items.length, 0);
43-
done();
4438
});
4539

46-
it('should remove all documents in test collection', function*(done) {
40+
it('should remove all documents in test collection', function*() {
4741
yield collection.remove({});
4842
var items = yield collection.find({});
4943
Assert.equal(items.length, 0);
50-
done();
5144
});
5245
});

test/downloader/busDownloader.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
/* global describe, it, before; */
3-
require('co-mocha')(require('mocha'));
43
const Assert = require('assert');
54

65
const base = '../../src';
@@ -18,32 +17,28 @@ describe('BusDownloader', () => {
1817
urlBRT = `http://${urlConfig.host}${urlConfig.path.bus.BRT}`;
1918
});
2019

21-
it('should download the current REGULAR buses states', function*(done) {
22-
var data = yield BusDownloader.fromURL(urlREGULAR);
23-
Assert.notEqual(data, undefined);
24-
Assert.notEqual(data, null);
25-
Assert(data instanceof Array);
26-
Assert(data[0] instanceof Bus);
27-
list = data;
28-
done();
20+
it('should download the current REGULAR buses states', function*() {
21+
list = yield BusDownloader.fromURL(urlREGULAR);
22+
Assert.notEqual(list, undefined);
23+
Assert.notEqual(list, null);
24+
Assert(list instanceof Array);
25+
Assert(list[0] instanceof Bus);
2926
});
3027

31-
it('should have the number count of docs in the array equal to the number of orders', (done) => {
28+
it('should have the number count of docs in the array equal to the number of orders', () => {
3229
const distinctOrders = [];
3330
for(let bus of list) {
3431
if(distinctOrders.indexOf(bus.order)>-1) continue;
3532
distinctOrders.push(bus.order);
3633
}
3734
Assert.equal(distinctOrders.length, list.length);
38-
done();
3935
});
4036

41-
it('should download the current BRT buses states', function*(done) {
37+
it('should download the current BRT buses states', function*() {
4238
var data = yield BusDownloader.fromURL(urlBRT);
4339
Assert.notEqual(data, undefined);
4440
Assert.notEqual(data, null);
4541
Assert(data instanceof Array);
4642
Assert(data[0] instanceof Bus);
47-
done();
4843
});
4944
});
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
/* global describe, it, before; */
3-
require('co-mocha')(require('mocha'));
43
const Assert = require('assert');
54

65
const base = '../../src';
@@ -9,11 +8,10 @@ const ItineraryDownloader = require(`${base}/downloader/itineraryDownloader`);
98

109
describe('ItineraryDownloader', () => {
1110

12-
it('should download the itinerary to line 485', function*(done) {
11+
it('should download the itinerary to line 485', function*() {
1312
var data = yield ItineraryDownloader.fromLine('485');
1413
Assert.notEqual(data, null);
1514
Assert.notEqual(data, undefined);
1615
Assert(data instanceof Itinerary);
17-
done();
1816
});
1917
});

0 commit comments

Comments
 (0)