Writing Points tests

This commit is contained in:
danibrutal
2015-06-19 12:04:25 +02:00
parent e4f5bb94d6
commit 90277f14a8
3 changed files with 19 additions and 9 deletions
+8
View File
@@ -51,6 +51,14 @@ class Database
}
/**
* @return string db name
*/
public function getName()
{
return $this->name;
}
/**
* Query influxDB
*
+2
View File
@@ -20,6 +20,8 @@ class Point
private $timestamp;
/**
* todo: Handle optional timestamp
*
* @param $measurement
* @param array $tags
* @param array $fields
+9 -9
View File
@@ -33,10 +33,8 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
$this->dataToInsert = file_get_contents(dirname(__FILE__) . '/input.example.json');
}
/**
* todo:
*/
public function testWrite()
public function testWritePointsInASingleCall()
{
$point1 = new Point(
'cpu_load_short',
@@ -44,7 +42,6 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
array('value' => 0.64),
'myTime'
);
$point2 = new Point(
'cpu_load_short',
array('host' =>'server01', 'region'=>'us-west'),
@@ -52,10 +49,13 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
'myTime'
);
//$this->db->writePoints(array($point1, $point2));
$payloadExpected ="$point1\n$point2";
$this->assertTrue(
true
);
$this->mockClient->expects($this->once())
->method('query')
->with($this->equalTo($this->db->getName()), $this->equalTo($payloadExpected))
->will($this->returnValue($this->equalTo('http://localhost:8086')));
$this->db->writePoints(array($point1, $point2));
}
}