Fixes spec on guzzle adapter

This commit is contained in:
Walter Dal Mut
2014-09-12 23:05:29 +02:00
parent b835c3a044
commit eacc092deb
2 changed files with 25 additions and 8 deletions
+22 -4
View File
@@ -6,6 +6,7 @@ use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use GuzzleHttp\Client;
use InfluxDB\Options;
use GuzzleHttp\Message\Response;
class GuzzleAdapterSpec extends ObjectBehavior
{
@@ -34,13 +35,30 @@ class GuzzleAdapterSpec extends ObjectBehavior
function it_should_query_data(Client $client, Options $options)
{
$client->get("select * from tcp.test", [])->willReturn([]);
$this->query("select * from tcp.test")->shouldReturn([]);
$client->get(
"localhost",
[
"auth" => ["one", "two"],
"query" => [
"q" => "select * from tcp.test",
]
]
)->willReturn(new Response(200,[],null));
$this->query("select * from tcp.test")->shouldReturn(null);
}
function it_should_query_data_with_time_precision(Client $client, Options $options)
{
$client->get("select * from tcp.test", ["time_precision" => "s"])->willReturn([]);
$this->query("select * from tcp.test", "s")->shouldReturn([]);
$client->get(
"localhost",
[
"auth" => ["one", "two"],
"query" => [
"time_precision" => "s",
"q" => "select * from tcp.test",
]
]
)->willReturn(new Response(200, [], null));
$this->query("select * from tcp.test", "s")->shouldReturn(null);
}
}
+3 -4
View File
@@ -55,10 +55,9 @@ class ClientTest extends \PHPUnit_Framework_TestCase
{
$this->object->mark("tcp.test", ["mark" => "element"]);
$cursor = $this->anotherClient->getDatabase($this->options->getDatabase())
->query("select * from tcp.test");
$this->assertCount(1, $cursor);
$this->assertEquals("element", $cursor[0]->mark);
$body = $this->object->query("select * from tcp.test");
$this->assertCount(1, $body[0]["points"]);
$this->assertEquals("element", $body[0]["points"][0][2]);
}
public function testGuzzleHttpQueryApiWorksCorrectly()