diff options
author | Richard Wall <richard@largo> | 2010-08-28 22:34:26 +0100 |
---|---|---|
committer | Richard Wall <richard@largo> | 2010-08-28 22:34:26 +0100 |
commit | 333dfba10d99e5a2eec391c2481156329e2949dc (patch) | |
tree | f890b13f90e2d2b8dc0a3058542accc01e921846 /jarmon | |
parent | 64f965d74374f3a15342bf6e807ac50513a69f68 (diff) |
the start of a builder of simple, testable rrd files
Diffstat (limited to 'jarmon')
-rw-r--r-- | jarmon/jarmon.js | 2 | ||||
-rw-r--r-- | jarmon/jarmon.test.js | 53 |
2 files changed, 45 insertions, 10 deletions
diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js index 6296fc5..24f967d 100644 --- a/jarmon/jarmon.js +++ b/jarmon/jarmon.js @@ -263,7 +263,7 @@ jarmon.RrdQuery.prototype.getData = function(startTime, endTime, dsId, cfName) { jarmon.RrdQueryRemote = function(url, unit, downloader) { this.url = url; this.unit = unit; - this.downloader = downloader; + this.downloader = downloader || jarmon.downloadBinary; this.lastUpdate = 0; this._download = null; }; diff --git a/jarmon/jarmon.test.js b/jarmon/jarmon.test.js index 86243b4..229b9a8 100644 --- a/jarmon/jarmon.test.js +++ b/jarmon/jarmon.test.js @@ -48,19 +48,54 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { Y.Test.Runner.add(new Y.Test.Case({ name: "jarmon.RrdQuery", + setUp: function() { + this.d = new jarmon.downloadBinary('simple.rrd') + .addCallback( + function(self, binary) { + try { + return new RRDFile(binary); + } catch(e) { + console.log(e); + } + }, this) + .addErrback( + function(ret) { + console.log(ret); + }); + }, + test_getDataTimeRangeOverlapError: function () { /** * The starttime must be less than the endtime **/ - var rq = new jarmon.RrdQuery({}, ''); - var error = null; - try { - rq.getData(1, 0); - } catch(e) { - error = e; - } - Y.Assert.isInstanceOf(jarmon.TimeRangeError, error); - } + this.d.addCallback( + function(self, rrd) { + self.resume(function() { + var rq = new jarmon.RrdQuery(self.rrd, ''); + var error = null; + try { + rq.getData(1, 0); + } catch(e) { + error = e; + } + Y.Assert.isInstanceOf(jarmon.TimeRangeError, error); + }); + }, this); + this.wait(); + }, + + test_getDataSimple: function () { + /** + * The starttime must be less than the endtime + **/ + this.d.addCallback( + function(self, rrd) { + self.resume(function() { + Y.Assert.areEqual(1, rrd.getLastUpdate()); + }); + }, this); + this.wait(); + }, })); |