Skip to content

Commit 271c6a8

Browse files
authored
Merge pull request #5 from UlisesGascon/improve-ci
Improved management for Mongo db uri reference
2 parents 00f3bd8 + 0401737 commit 271c6a8

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ before_script:
2323
## else it would block execution and hang travis
2424
- docker run -d -p 27017:27017 mongo:4.0
2525
- docker ps -a
26-
- npm start -- --silent &
27-
env:
28-
- MONGODB_URI=mongodb://localhost:27017/nodegoat
26+
- NODE_ENV=test npm start -- --silent &
27+
2928
script:
3029
- npm run test:ci
3130

config/env/all.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// default app configuration
2+
3+
var port = process.env.PORT || 4000;
4+
var db = process.env.NODE_ENV === 'test' ? "mongodb://localhost:27017/nodegoat" : "mongodb://nodegoat:owasp@ds159217.mlab.com:59217/nodegoat";
5+
db = db || process.env.MONGOLAB_URI || process.env.MONGODB_URI;
6+
27
module.exports = {
3-
port: process.env.PORT || 4000,
4-
db: process.env.MONGOLAB_URI || process.env.MONGODB_URI || "mongodb://nodegoat:owasp@ds159217.mlab.com:59217/nodegoat",
8+
port: port,
9+
db: db,
510
cookieSecret: "session_cookie_secret_key_here",
611
cryptoKey: "a_secure_key_for_crypto_here",
712
cryptoAlgo: "aes256",

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
"//": "a9 insecure components"
2727
},
2828
"scripts": {
29-
"start": "MONGODB_URI=mongodb://localhost:27017/nodegoat node server.js",
30-
"test:e2e": "cypress open",
31-
"test:ci": "MONGODB_URI=mongodb://localhost:27017/nodegoat cypress run",
29+
"start": "node server.js",
30+
"test:e2e": "NODE_ENV=test cypress open",
31+
"test:ci": "NODE_ENV=test cypress run",
3232
"test": "node node_modules/grunt-cli/bin/grunt test",
33-
"db:seed": "grunt db-reset",
33+
"db:seed": "NODE_ENV=test grunt db-reset",
3434
"precommit": "grunt precommit",
3535
"docker-mongo": "docker run -p 27017:27017 --name mongo mongo:latest",
3636
"start-infra": "docker-compose up",

test/e2e/support/commands.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ Cypress.Commands.add('visitPage', (path = '/', config = {}) => {
2626
})
2727

2828
Cypress.Commands.add('dbReset', () => {
29-
//@see: https://github.com/topheman/react-fiber-experiments/blame/master/cypress/integration/about.spec.js#L34
3029
cy.exec('npm run db:seed', {
3130
timeout: 6000,
3231
failOnNonZeroExit: false
3332
})
34-
// @TODO: Just commented for CI, this MUST be improved
35-
//.its('stdout').should('contain', 'Database reset performed successfully')
3633
})

0 commit comments

Comments
 (0)