Explorar el Código

Add coverage reporting

Matt Coles hace 9 años
padre
commit
03c84486e5
Se han modificado 4 ficheros con 10 adiciones y 3 borrados
  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,3 +1,4 @@
1
+coverage/
1 2
 node_modules/
2 3
 debug.log
3 4
 logpasswd

+ 4 - 1
index.js

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

+ 4 - 2
package.json

@@ -4,9 +4,9 @@
4 4
   "description": "Server for the IP project",
5 5
   "main": "index.js",
6 6
   "scripts": {
7
-    "pretest": "node index.js > debug.log &",
7
+    "pretest": "istanbul cover index.js > debug.log &",
8 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 11
   "repository": {
12 12
     "type": "git",
@@ -28,6 +28,8 @@
28 28
     "serve-index": "^1.7.3"
29 29
   },
30 30
   "devDependencies": {
31
+    "coveralls": "^2.11.9",
32
+    "istanbul": "^0.4.3",
31 33
     "jasmine": "^2.4.1",
32 34
     "jasmine-spec-reporter": "^2.4.0"
33 35
   }

+ 1 - 0
presenters/notification-controller.js

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