From eacc092debf596cf64060c61131888b38ed799eb Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Sep 2014 23:05:29 +0200 Subject: [PATCH] Fixes spec on guzzle adapter --- spec/InfluxDB/Adapter/GuzzleAdapterSpec.php | 26 +++++++++++++++++---- tests/InfluxDB/ClientTest.php | 7 +++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php index 3befd1b72..5c61ce1bb 100644 --- a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php +++ b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php @@ -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); } } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index ec6581510..566150f7d 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -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()