Skip to content

Commit e26d9ae

Browse files
authored
Merge pull request #19 from ByteInternet/add_append_labels_test
2 parents 7a2047e + 95015c9 commit e26d9ae

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

banaan.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use Hypernode\Api\HypernodeClientFactory;
4+
5+
require_once 'vendor/autoload.php';
6+
7+
$client = HypernodeClientFactory::create('1298269edeef1c19f05883e800d95bef2eca5212');
8+
9+
$active = $client->brancherApp->list('hntestgroot');
10+
11+
var_dump($active[0]['labels']);
12+
13+
$result = $client->brancherApp->update('hntestgroot-ephx0u2z7', ['labels' => ['mykey='.time()]]);
14+
15+
var_dump($result);

tests/unit/Service/BrancherAppTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,46 @@ public function testUpdateBrancherApp()
183183
);
184184
}
185185

186+
public function testUpdateBrancherAppAppendsLabels()
187+
{
188+
$this->responses->append(
189+
// List Brancher apps
190+
new Response(200, [], json_encode([
191+
'branchers' => [
192+
[
193+
'name' => 'johndoe-eph123456',
194+
'labels' => ['key1' => 'value1']
195+
]
196+
]
197+
])),
198+
// Update Brancher app
199+
new Response(200, [], json_encode([
200+
'labels' => [
201+
'key1' => 'value1',
202+
'key2' => 'value2',
203+
]
204+
])),
205+
);
206+
207+
$result = $this->client->brancherApp->update(
208+
'johndoe-eph123456', ['labels' => ['key2=value2']],
209+
true
210+
);
211+
212+
$request = $this->responses->getLastRequest();
213+
$this->assertEquals('PUT', $request->getMethod());
214+
$this->assertEquals('/v2/brancher/johndoe-eph123456/', $request->getUri());
215+
$this->assertJson((string)$request->getBody());
216+
$this->assertEquals(
217+
['labels' => ['key2=value2', 'key1=value1']],
218+
json_decode((string)$request->getBody(), true)
219+
);
220+
$this->assertEquals(
221+
['labels' => [ 'key1' => 'value1', 'key2' => 'value2']],
222+
$result
223+
);
224+
}
225+
186226
public function testUpdateBrancherAppRaisesClientExceptions()
187227
{
188228
$badRequestResponse = new Response(400, [], json_encode([

0 commit comments

Comments
 (0)