Browse Source

Add coverage reporting

Matt Coles 9 years ago
parent
commit
03c84486e5
4 changed files with 10 additions and 3 deletions
  1. 1 0
      .gitignore
  2. 4 1
      index.js
  3. 4 2
      package.json
  4. 1 0
      presenters/notification-controller.js

+ 1 - 0
.gitignore

1
+coverage/
1
 node_modules/
2
 node_modules/
2
 debug.log
3
 debug.log
3
 logpasswd
4
 logpasswd

+ 4 - 1
index.js

11
 var fs = require('fs');
11
 var fs = require('fs');
12
 var logDirectory = 'log'
12
 var logDirectory = 'log'
13
 var production = process.argv[2];
13
 var production = process.argv[2];
14
+/* istanbul ignore if */
14
 if (production === "-p") {
15
 if (production === "-p") {
15
   var log_passwd = fs.readFileSync('logpasswd', 'utf-8');
16
   var log_passwd = fs.readFileSync('logpasswd', 'utf-8');
16
 }
17
 }
17
 
18
 
18
 scheduler.register_existing_events();
19
 scheduler.register_existing_events();
19
-
20
+/* istanbul ignore next */
20
 var auth = function (req, res, next) {
21
 var auth = function (req, res, next) {
21
   function unauthorized(res) {
22
   function unauthorized(res) {
22
     res.set('WWW-Authenticate', 'Basic realm=Authorization Required');
23
     res.set('WWW-Authenticate', 'Basic realm=Authorization Required');
61
 app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
62
 app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
62
 app.use('/', route_manager);
63
 app.use('/', route_manager);
63
 app.use('/source', require('magic-window')('/source', { ignore: ['config', 'redis', 'cert.pem', 'key.pem', 'dump.rdb', 'logpasswd'] }))
64
 app.use('/source', require('magic-window')('/source', { ignore: ['config', 'redis', 'cert.pem', 'key.pem', 'dump.rdb', 'logpasswd'] }))
65
+/* istanbul ignore if */
64
 if (production === "-p") {
66
 if (production === "-p") {
65
   app.use('/log', auth, express.static('log'));
67
   app.use('/log', auth, express.static('log'));
66
   app.use('/log', auth, serveIndex('log', {'icons': true}));
68
   app.use('/log', auth, serveIndex('log', {'icons': true}));
70
   console.log('Now accepting connections on port 3000.');
72
   console.log('Now accepting connections on port 3000.');
71
 });
73
 });
72
 
74
 
75
+/* istanbul ignore if */
73
 if (production === "-p") {
76
 if (production === "-p") {
74
   var prkey = fs.readFileSync('key.pem');
77
   var prkey = fs.readFileSync('key.pem');
75
   var certi = fs.readFileSync('cert.pem');
78
   var certi = fs.readFileSync('cert.pem');

+ 4 - 2
package.json

4
   "description": "Server for the IP project",
4
   "description": "Server for the IP project",
5
   "main": "index.js",
5
   "main": "index.js",
6
   "scripts": {
6
   "scripts": {
7
-    "pretest": "node index.js > debug.log &",
7
+    "pretest": "istanbul cover index.js > debug.log &",
8
     "test": "sleep 2; node jasmine-runner.js; node utils/flushdb.js",
8
     "test": "sleep 2; node jasmine-runner.js; node utils/flushdb.js",
9
-    "posttest": "killall node"
9
+    "posttest": "killall -2 node && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
10
   },
10
   },
11
   "repository": {
11
   "repository": {
12
     "type": "git",
12
     "type": "git",
28
     "serve-index": "^1.7.3"
28
     "serve-index": "^1.7.3"
29
   },
29
   },
30
   "devDependencies": {
30
   "devDependencies": {
31
+    "coveralls": "^2.11.9",
32
+    "istanbul": "^0.4.3",
31
     "jasmine": "^2.4.1",
33
     "jasmine": "^2.4.1",
32
     "jasmine-spec-reporter": "^2.4.0"
34
     "jasmine-spec-reporter": "^2.4.0"
33
   }
35
   }

+ 1 - 0
presenters/notification-controller.js

1
+ /* istanbul ignore next */
1
 module.exports = {
2
 module.exports = {
2
 
3
 
3
   send_notifications_for: function (event_id) {
4
   send_notifications_for: function (event_id) {