From 74219895ef96b33a759486ccd961e5cded2030ad Mon Sep 17 00:00:00 2001 From: danibrutal Date: Thu, 18 Jun 2015 16:17:57 +0200 Subject: [PATCH] Testing database --- src/Leaseweb/InfluxDB/Database.php | 1 + tests/unit/DatabaseTest.php | 42 ++++++++++++++++++++++++++++++ tests/unit/input.example.json | 17 ++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 tests/unit/DatabaseTest.php create mode 100644 tests/unit/input.example.json diff --git a/src/Leaseweb/InfluxDB/Database.php b/src/Leaseweb/InfluxDB/Database.php index 8a594abd6..37ca65cb9 100644 --- a/src/Leaseweb/InfluxDB/Database.php +++ b/src/Leaseweb/InfluxDB/Database.php @@ -110,6 +110,7 @@ class Database return $this->query(sprintf('SHOW RETENTION POLICIES %s', $this->name))->getPoints(); } + /** * Drop this database */ diff --git a/tests/unit/DatabaseTest.php b/tests/unit/DatabaseTest.php new file mode 100644 index 000000000..336ce3a7e --- /dev/null +++ b/tests/unit/DatabaseTest.php @@ -0,0 +1,42 @@ +mockClient = $this->getMockBuilder('\Leaseweb\InfluxDB\Client') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockClient->expects($this->any()) + ->method('getBaseURI') + ->will($this->returnValue($this->equalTo('http://localhost:8086'))); + + $this->db = new Database('influx_test_db', $this->mockClient); + + $this->dataToInsert = file_get_contents(dirname(__FILE__) . '/input.example.json'); + + } + + public function testWrite() + { + $this->assertTrue( + 'mockClient' + ); + } +} \ No newline at end of file diff --git a/tests/unit/input.example.json b/tests/unit/input.example.json new file mode 100644 index 000000000..f47806261 --- /dev/null +++ b/tests/unit/input.example.json @@ -0,0 +1,17 @@ +{ + "database": "mydb", + "retentionPolicy": "mypolicy", + "points": [ + { + "measurement": "cpu_load_short", + "tags": { + "host": "server01", + "region": "us-west" + }, + "time": "2009-11-10T23:00:00Z", + "fields": { + "value": 0.64 + } + } + ] +} \ No newline at end of file