From 877f4724204f0d68f44116ef21b8425813c8285d Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Sun, 29 Aug 2010 23:16:18 +0100 Subject: a filing test for RrdQuery getData --- jarmon/jarmon.test.js | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/jarmon/jarmon.test.js b/jarmon/jarmon.test.js index 3d96d5a..6360685 100644 --- a/jarmon/jarmon.test.js +++ b/jarmon/jarmon.test.js @@ -52,11 +52,7 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { this.d = new jarmon.downloadBinary('build/test.rrd') .addCallback( function(self, binary) { - try { - return new RRDFile(binary); - } catch(e) { - console.log(e); - } + return new RRDFile(binary); }, this) .addErrback( function(ret) { @@ -143,10 +139,7 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { }); }, this); this.wait(); - }, - - - + } })); Y.Test.Runner.add(new Y.Test.Case({ @@ -156,11 +149,7 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { this.d = new jarmon.downloadBinary('build/test.rrd') .addCallback( function(self, binary) { - try { - return new RRDFile(binary); - } catch(e) { - console.log(e); - } + return new RRDFile(binary); }, this) .addErrback( function(ret) { @@ -188,34 +177,31 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { this.wait(); }, - test_getDataSimple: function () { + test_getData: function () { /** * The generated rrd file should have values 0-9 at 1s intervals - * starting at 1980-01-01 00:00:00 + * starting at 1980-01-01 00:00:01 + * Result should include a data points with times > starttime and + * <= endTime **/ this.d.addCallback( function(self, rrd) { self.resume(function() { - var rra = rrd.getRRA(0) - console.log(rra.getEl(0, 0)); - - - var firstUpdate = new Date('1 jan 1980 00:00:00').getTime(); - var lastUpdate = firstUpdate + 10*1000; - Y.Assert.areEqual( - lastUpdate/1000, rrd.getLastUpdate()); + var startTime = new Date('1 jan 1980 00:00:00').getTime(); + var endTime = new Date('1 jan 1980 00:00:10').getTime(); - - /* var q = new jarmon.RrdQuery(rrd, ''); - var data = q.getData(firstUpdate, lastUpdate); + var data = q.getData(startTime, endTime); + Y.Assert.areEqual( + 10, data.data.length); Y.Assert.areEqual( - firstUpdate+1000, data.data[0][0]); - */ + startTime+1000, data.data[0][0]); + Y.Assert.areEqual( + endTime, data.data[9][0]); }); }, this); this.wait(); - }, + } })); -- cgit v1.2.3-2-g168b