Skip to content

Commit

Permalink
chore:refactor memcached test (#1698)
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl authored Apr 16, 2020
1 parent ad7a245 commit ad7cd89
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion appengine/memcached/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ app.get('/', async (req, res, next) => {
});

const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
const server = app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});

module.exports = server;
6 changes: 4 additions & 2 deletions appengine/memcached/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
},
"scripts": {
"start": "node app.js",
"test": "repo-tools test app"
"test": "mocha --exit test/*.test.js"
},
"dependencies": {
"express": "^4.16.4",
"memjs": "^1.2.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0"
"chai": "^4.2.0",
"mocha": "^7.1.1",
"wait-port": "^0.2.7"
}
}
13 changes: 13 additions & 0 deletions appengine/memcached/test/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const waitPort = require('wait-port');
const {expect} = require('chai');

const PORT = process.env.PORT || 8080;

describe('server listening', () => {
it('should be listening', async () => {
const server = require('../app.js');
const isOpen = await waitPort({port: PORT});
expect(isOpen).to.be.true;
server.close();
});
});

0 comments on commit ad7cd89

Please sign in to comment.