mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Throws InfluxDBClientError if there was an error after quering
This commit is contained in:
@@ -73,11 +73,18 @@ class ResultSet
|
||||
* results is an array of objects, one for each query,
|
||||
* each containing the keys for a series
|
||||
*
|
||||
* @throws InfluxDBClientError
|
||||
*
|
||||
* @return array $series
|
||||
*/
|
||||
public function getSeries()
|
||||
{
|
||||
$pickSeries = function ($object) {
|
||||
|
||||
if (isset($object['error'])) {
|
||||
throw new InfluxDBClientError($object['error']);
|
||||
}
|
||||
|
||||
return $object['series'];
|
||||
};
|
||||
|
||||
|
||||
@@ -40,6 +40,27 @@ EOD;
|
||||
new ResultSet($errorResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws Exception if something went wrong with influxDB after processing the query
|
||||
* @expectedException \Leaseweb\InfluxDB\InfluxDBClientError
|
||||
*/
|
||||
public function testThrowsInfluxDBExceptionIfAnyErrorInSeries()
|
||||
{
|
||||
|
||||
$errorResult = <<<EOD
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"series": [],
|
||||
"error": "There was an error after querying"
|
||||
}
|
||||
]
|
||||
}
|
||||
EOD;
|
||||
$rs = new ResultSet($errorResult);
|
||||
$rs->getSeries();
|
||||
}
|
||||
|
||||
/**
|
||||
* We can get points from measurement
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user