-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with getting status of respository and snapshots. (#719)
- Loading branch information
1 parent
8d963c6
commit 2d11682
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tests/Elasticsearch/Tests/Endpoints/StatusEndpointTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Elasticsearch\Tests\Endpoints; | ||
|
||
use Elasticsearch\Endpoints\Snapshot\Status; | ||
use Elasticsearch\Common\Exceptions; | ||
|
||
class StatusEndpointTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
private $endpoint; | ||
|
||
protected function setUp() | ||
{ | ||
$this->endpoint = new Status(); | ||
} | ||
|
||
public static function statusParams() | ||
{ | ||
return [ | ||
[ | ||
'repository' => 'my_backup', | ||
'snapshot' => null, | ||
'expected' => '/_snapshot/my_backup/_status', | ||
], | ||
[ | ||
'repository' => 'my_backup', | ||
'snapshot' => 'snapshot_1', | ||
'expected' => '/_snapshot/my_backup/snapshot_1/_status', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider statusParams | ||
*/ | ||
public function testGetUriReturnsAppropriateUri($repository, $snapshot, $expected) | ||
{ | ||
if ($repository) { | ||
$this->endpoint->setRepository($repository); | ||
} | ||
|
||
if ($snapshot) { | ||
$this->endpoint->setSnapshot($snapshot); | ||
} | ||
|
||
$this->assertSame($expected, $this->endpoint->getURI()); | ||
} | ||
|
||
public function testMissingRepositoryThrowsException() | ||
{ | ||
|
||
$this->expectException(Exceptions\RuntimeException::class); | ||
|
||
$this->endpoint->setSnapshot('should fail'); | ||
$this->endpoint->getURI(); | ||
} | ||
} |