Skip to content

Commit

Permalink
Merge pull request #5 from UlisesGascon/improve-ci
Browse files Browse the repository at this point in the history
Improved management for Mongo db uri reference
  • Loading branch information
UlisesGascon authored Aug 2, 2019
2 parents 00f3bd8 + 0401737 commit 271c6a8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ before_script:
## else it would block execution and hang travis
- docker run -d -p 27017:27017 mongo:4.0
- docker ps -a
- npm start -- --silent &
env:
- MONGODB_URI=mongodb://localhost:27017/nodegoat
- NODE_ENV=test npm start -- --silent &

script:
- npm run test:ci

9 changes: 7 additions & 2 deletions config/env/all.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// default app configuration

var port = process.env.PORT || 4000;
var db = process.env.NODE_ENV === 'test' ? "mongodb://localhost:27017/nodegoat" : "mongodb://nodegoat:[email protected]:59217/nodegoat";
db = db || process.env.MONGOLAB_URI || process.env.MONGODB_URI;

module.exports = {
port: process.env.PORT || 4000,
db: process.env.MONGOLAB_URI || process.env.MONGODB_URI || "mongodb://nodegoat:[email protected]:59217/nodegoat",
port: port,
db: db,
cookieSecret: "session_cookie_secret_key_here",
cryptoKey: "a_secure_key_for_crypto_here",
cryptoAlgo: "aes256",
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"//": "a9 insecure components"
},
"scripts": {
"start": "MONGODB_URI=mongodb://localhost:27017/nodegoat node server.js",
"test:e2e": "cypress open",
"test:ci": "MONGODB_URI=mongodb://localhost:27017/nodegoat cypress run",
"start": "node server.js",
"test:e2e": "NODE_ENV=test cypress open",
"test:ci": "NODE_ENV=test cypress run",
"test": "node node_modules/grunt-cli/bin/grunt test",
"db:seed": "grunt db-reset",
"db:seed": "NODE_ENV=test grunt db-reset",
"precommit": "grunt precommit",
"docker-mongo": "docker run -p 27017:27017 --name mongo mongo:latest",
"start-infra": "docker-compose up",
Expand Down
3 changes: 0 additions & 3 deletions test/e2e/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ Cypress.Commands.add('visitPage', (path = '/', config = {}) => {
})

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

0 comments on commit 271c6a8

Please sign in to comment.