mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
git-subtree-dir: lib/influxdb-php-sdk git-subtree-mainline:15a338061dgit-subtree-split:1928d59eb9
84 lines
2.1 KiB
PHP
84 lines
2.1 KiB
PHP
<?php
|
|
namespace InfluxDB;
|
|
|
|
use DateTime;
|
|
use DateTimeZone;
|
|
use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter;
|
|
use InfluxDB\Options;
|
|
use InfluxDB\Adapter\UdpAdapter;
|
|
use GuzzleHttp\Client as GuzzleHttpClient;
|
|
|
|
class ClientTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
public function testMarkNewMeasurementWithShortSyntax()
|
|
{
|
|
$mock = $this->prophesize("InfluxDB\\Adapter\\WritableInterface");
|
|
$mock->send([
|
|
"points" => [
|
|
[
|
|
"measurement" => "tcp.test",
|
|
"fields" => [
|
|
"mark" => "element"
|
|
]
|
|
]
|
|
]
|
|
])->shouldBeCalledTimes(1);
|
|
|
|
$object = new Client($mock->reveal());
|
|
$object->mark("tcp.test", ["mark" => "element"]);
|
|
}
|
|
|
|
public function testWriteDirectMessages()
|
|
{
|
|
$mock = $this->prophesize("InfluxDB\\Adapter\\WritableInterface");
|
|
$mock->send([
|
|
"tags" => [
|
|
"dc" => "eu-west-1",
|
|
],
|
|
"points" => [
|
|
[
|
|
"measurement" => "vm-serie",
|
|
"fields" => [
|
|
"cpu" => 18.12,
|
|
"free" => 712423,
|
|
]
|
|
]
|
|
]
|
|
])->shouldBeCalledTimes(1);
|
|
$object = new Client($mock->reveal());
|
|
|
|
$object->mark([
|
|
"tags" => [
|
|
"dc" => "eu-west-1",
|
|
],
|
|
"points" => [
|
|
[
|
|
"measurement" => "vm-serie",
|
|
"fields" => [
|
|
"cpu" => 18.12,
|
|
"free" => 712423,
|
|
],
|
|
],
|
|
]
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @expectedException BadMethodCallException
|
|
*/
|
|
public function testNeedWritableInterfaceDuringMark()
|
|
{
|
|
$client = new Client(new \stdClass());
|
|
$client->mark("OK", []);
|
|
}
|
|
|
|
/**
|
|
* @expectedException BadMethodCallException
|
|
*/
|
|
public function testNeedQueryableInterfaceDuringQuery()
|
|
{
|
|
$client = new Client(new \stdClass());
|
|
$client->query("OK", []);
|
|
}
|
|
}
|