coverage/lcov-report/lib/ping_services/smtp.js.html
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for lib/ping_services/smtp.js</title>
<meta charset="utf-8">
<link rel="stylesheet" href="../../prettify.css">
<link rel="stylesheet" href="../../base.css">
<style type='text/css'>
div.coverage-summary .sorter {
background-image: url(../../sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class="header medium">
<h1>Code coverage report for <span class="entity">lib/ping_services/smtp.js</span></h1>
<h2>
Statements: <span class="metric">79.17% <small>(19 / 24)</small></span>
Branches: <span class="metric">70% <small>(7 / 10)</small></span>
Functions: <span class="metric">66.67% <small>(4 / 6)</small></span>
Lines: <span class="metric">79.17% <small>(19 / 24)</small></span>
Ignored: <span class="metric"><span class="ignore-none">none</span></span>
</h2>
<div class="path"><a href="../../index.html">All files</a> » <a href="index.html">lib/ping_services/</a> » smtp.js</div>
</div>
<div class="body">
<pre><table class="coverage">
<tr><td class="line-count">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44</td><td class="line-coverage"><span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var net = require('net');
function ping (service, callback){
var startTime = new Date();
var timeout = service.timeout || 10000;
var socket = net.createConnection(service.host.port, service.host.host); // http://nodejs.org/api/net.html
var callbackExecuted = false;
socket.setTimeout(service.timeout || 10000, function () {
callbackExecuted = true;
socket.end("bye!");
callback('Timeout (took more than ' + timeout + ' ms)', null, null, null);
});
//TODO: implement logic to validate and actual SMTP server (here we are just checking that it responds)
socket.on("data", <span class="fstat-no" title="function not covered" >function (c) {</span>
<span class="cstat-no" title="statement not covered" > socket.end("bye!");</span>
});
socket.on("error", function () { // The 'close' event will be called directly following this event.
if (!callbackExecuted) {
callback("Could not open socket", null, null, null);
}
callbackExecuted = true;
});
socket.on("close", function () {
<span class="missing-if-branch" title="if path not taken" >I</span>if (!callbackExecuted) {
<span class="cstat-no" title="statement not covered" > callback("Socket closed", null, null, null);</span>
}
});
socket.on("end", <span class="fstat-no" title="function not covered" >function (data) {</span>
<span class="cstat-no" title="statement not covered" > if (!callbackExecuted) {</span>
<span class="cstat-no" title="statement not covered" > var timeDiff = (new Date() - startTime);</span>
<span class="cstat-no" title="statement not covered" > callback(null, null, null, timeDiff);</span>
}
});
}
module.exports.ping = ping;
</pre></td></tr>
</table></pre>
</div>
<div class="footer">
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Wed Apr 01 2015 23:27:01 GMT+1100 (AEDT)</div>
</div>
<script src="../../prettify.js"></script>
<script>
window.onload = function () {
if (typeof prettyPrint === 'function') {
prettyPrint();
}
};
</script>
<script src="../../sorter.js"></script>
</body>
</html>