Skip to content

Commit 0065ee0

Browse files
committed
test: client works with and without slash at the and of url (influxdata/influxdb-client-python#87)
1 parent 8d61046 commit 0065ee0

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

tests/BasicTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ abstract class BasicTest extends TestCase
3131

3232
/**
3333
* @before
34+
* @param $url
3435
*/
35-
public function setUp()
36+
public function setUp($url = "http://localhost:9999")
3637
{
3738
$this->client = new Client([
38-
"url" => "http://localhost:9999",
39+
"url" => $url,
3940
"token" => "my-token",
4041
"bucket" => "my-bucket",
4142
"precision" => WritePrecision::NS,

tests/DefaultApiTest.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace InfluxDB2Test;
44

55
use GuzzleHttp\Psr7\Response;
6-
use InvalidArgumentException;
76
use InfluxDB2\ApiException;
7+
use InvalidArgumentException;
88

99
require_once('BasicTest.php');
1010

@@ -21,6 +21,26 @@ public function testUserAgent()
2121
strval($request->getHeader("User-Agent")[0]));
2222
}
2323

24+
public function testTrailingSlashInUrl()
25+
{
26+
$this->mockHandler->append(new Response(204));
27+
$this->writeApi->write('h2o,location=west value=33i 15');
28+
29+
$request = $this->mockHandler->getLastRequest();
30+
31+
$this->assertEquals('http://localhost:9999/api/v2/write?org=my-org&bucket=my-bucket&precision=ns', strval($request->getUri()));
32+
33+
$this->tearDown();
34+
$this->setUp("http://localhost:9999/");
35+
36+
$this->mockHandler->append(new Response(204));
37+
$this->writeApi->write('h2o,location=west value=33i 15');
38+
39+
$request = $this->mockHandler->getLastRequest();
40+
41+
$this->assertEquals('http://localhost:9999/api/v2/write?org=my-org&bucket=my-bucket&precision=ns', strval($request->getUri()));
42+
}
43+
2444
public function testContentType()
2545
{
2646
$this->mockHandler->append(new Response(204));

0 commit comments

Comments
 (0)