mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added influxdb library
This commit is contained in:
60
lib/influxdb-php/tests/unit/ClientTest.php
Normal file
60
lib/influxdb-php/tests/unit/ClientTest.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace InfluxDB\Test;
|
||||
|
||||
use InfluxDB\Client;
|
||||
use InfluxDB\Driver\Guzzle;
|
||||
|
||||
class ClientTest extends AbstractTest
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/** @var Client $client */
|
||||
protected $client = null;
|
||||
|
||||
public function testBaseURl()
|
||||
{
|
||||
$client = new Client('localhost', 8086);
|
||||
|
||||
$this->assertEquals($client->getBaseURI(), 'http://localhost:8086');
|
||||
}
|
||||
|
||||
public function testSelectDbShouldReturnDatabaseInstance()
|
||||
{
|
||||
$client = new Client('localhost', 8086);
|
||||
|
||||
$dbName = 'test-database';
|
||||
$database = $client->selectDB($dbName);
|
||||
|
||||
$this->assertInstanceOf('\InfluxDB\Database', $database);
|
||||
|
||||
$this->assertEquals($dbName, $database->getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testGuzzleQuery()
|
||||
{
|
||||
$client = new Client('localhost', 8086);
|
||||
$query = "some-bad-query";
|
||||
|
||||
$bodyResponse = file_get_contents(dirname(__FILE__) . '/result.example.json');
|
||||
$httpMockClient = $this->buildHttpMockClient($bodyResponse);
|
||||
|
||||
$client->setDriver(new Guzzle($httpMockClient));
|
||||
|
||||
/** @var \InfluxDB\ResultSet $result */
|
||||
$result = $client->query(null, $query);
|
||||
|
||||
$this->assertInstanceOf('\InfluxDB\ResultSet', $result);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user