Skip to content

Commit 800e6e2

Browse files
committed
Separate unit tests for Server model
1 parent 2fca41c commit 800e6e2

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

tests/unit/Compute/v2/Models/ServerTest.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public function setUp()
2626
$this->server->id = 'serverId';
2727
}
2828

29-
/**
30-
* @expectedException \RuntimeException
31-
*/
3229
public function test_it_creates()
3330
{
3431
$opts = [
@@ -45,12 +42,36 @@ public function test_it_creates()
4542

4643
$this->setupMock('POST', 'servers', $expectedJson, [], 'server-post');
4744
$this->assertInstanceOf(Server::class, $this->server->create($opts));
45+
}
4846

47+
public function test_it_creates_with_boot_from_volume()
48+
{
4949
$opts = [
5050
'name' => 'foo',
5151
'flavorId' => 'baz',
52+
'blockDeviceMapping' => [['uuid' => 'aaaa-ddddd-bbbb-ccccc']]
5253
];
53-
$this->server->create($opts);
54+
55+
$expectedJson = ['server' => [
56+
'name' => $opts['name'],
57+
'flavorRef' => $opts['flavorId'],
58+
'block_device_mapping_v2' => $opts['blockDeviceMapping']
59+
]];
60+
61+
$this->setupMock('POST', 'servers', $expectedJson, [], 'server-post');
62+
$this->assertInstanceOf(Server::class, $this->server->create($opts));
63+
}
64+
65+
/**
66+
* @expectedException \RuntimeException
67+
* @expectedExceptionMessage imageId or blockDeviceMapping.uuid must be set.
68+
*/
69+
public function test_it_requires_image_id_or_volume_id_to_create_servers()
70+
{
71+
$this->server->create([
72+
'name' => 'some-server-name',
73+
'flavorId' => 'apple'
74+
]);
5475
}
5576

5677
public function test_it_updates()

tests/unit/Compute/v2/ServiceTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
class ServiceTest extends TestCase
2020
{
21+
/** @var Service */
2122
private $service;
2223

2324
public function setUp()

0 commit comments

Comments
 (0)