Skip to content

Commit 44fdab1

Browse files
committed
Added unit tests for Gnocchi Service
1 parent 3758695 commit 44fdab1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/unit/Metric/v1/Gnocchi/ServiceTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace OpenStack\Test\Metric\v1\Gnocchi;
34

45
use OpenStack\Metric\v1\Gnocchi\Models\Metric;
@@ -12,34 +13,43 @@ class ServiceTest extends TestCase
1213
{
1314
/** @var Service */
1415
private $service;
16+
1517
public function setUp()
1618
{
1719
parent::setUp();
1820
$this->rootFixturesDir = __DIR__;
1921
$this->service = new Service($this->client->reveal(), new Api());
2022
}
23+
2124
public function test_it_lists_resource_types()
2225
{
2326
$this->client
2427
->request('GET', 'v1/resource_type', ['headers' => []])
2528
->shouldBeCalled()
2629
->willReturn($this->getFixture('resourcetypes-get'));
30+
2731
$result = $this->service->listResourceTypes();
32+
2833
$this->assertContainsOnlyInstancesOf(ResourceType::class, $result);
2934
}
35+
3036
public function test_it_lists_resources()
3137
{
3238
$this->client
3339
->request('GET', 'v1/resource/generic', ['headers' => [], 'query' => ['limit' => 3]])
3440
->shouldBeCalled()
3541
->willReturn($this->getFixture('resources-get'));
42+
3643
$result = $this->service->listResources(['limit' => 3]);
44+
3745
$this->assertContainsOnlyInstancesOf(Resource::class, $result);
3846
}
47+
3948
public function test_it_get_resource()
4049
{
4150
$this->assertInstanceOf(Resource::class, $this->service->getResource(['id' => '1']));
4251
}
52+
4353
public function test_it_search_resources()
4454
{
4555
$this->client
@@ -49,24 +59,31 @@ public function test_it_search_resources()
4959
$result = $this->service->searchResources(['type' => 'generic']);
5060
$this->assertContainsOnlyInstancesOf(Resource::class, $result);
5161
}
62+
5263
public function test_it_search_resources_with_custom_type()
5364
{
5465
$this->client
5566
->request('POST', 'v1/search/resource/instance', ['headers' => ['Content-Type' => 'application/json']])
5667
->shouldBeCalled()
5768
->willReturn($this->getFixture('resources-get'));
69+
5870
$result = $this->service->searchResources(['type' => 'instance']);
71+
5972
$this->assertContainsOnlyInstancesOf(Resource::class, $result);
6073
}
74+
6175
public function test_it_lists_metrics()
6276
{
6377
$this->client
6478
->request('GET', 'v1/metric', ['headers' => [], 'query' => ['limit' => 5]])
6579
->shouldBeCalled()
6680
->willReturn($this->getFixture('metrics-get'));
81+
6782
$result = $this->service->listMetrics(['limit' => 5]);
83+
6884
$this->assertContainsOnlyInstancesOf(Metric::class, $result);
6985
}
86+
7087
public function test_it_get_metric()
7188
{
7289
$this->assertInstanceOf(Metric::class, $this->service->getMetric('metric-id'));

0 commit comments

Comments
 (0)