Skip to content

Commit

Permalink
Merge pull request #19 from ByteInternet/add_append_labels_test
Browse files Browse the repository at this point in the history
  • Loading branch information
tdgroot authored Apr 5, 2023
2 parents 7a2047e + 95015c9 commit e26d9ae
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
15 changes: 15 additions & 0 deletions banaan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Hypernode\Api\HypernodeClientFactory;

require_once 'vendor/autoload.php';

$client = HypernodeClientFactory::create('1298269edeef1c19f05883e800d95bef2eca5212');

$active = $client->brancherApp->list('hntestgroot');

var_dump($active[0]['labels']);

$result = $client->brancherApp->update('hntestgroot-ephx0u2z7', ['labels' => ['mykey='.time()]]);

var_dump($result);
40 changes: 40 additions & 0 deletions tests/unit/Service/BrancherAppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,46 @@ public function testUpdateBrancherApp()
);
}

public function testUpdateBrancherAppAppendsLabels()
{
$this->responses->append(
// List Brancher apps
new Response(200, [], json_encode([
'branchers' => [
[
'name' => 'johndoe-eph123456',
'labels' => ['key1' => 'value1']
]
]
])),
// Update Brancher app
new Response(200, [], json_encode([
'labels' => [
'key1' => 'value1',
'key2' => 'value2',
]
])),
);

$result = $this->client->brancherApp->update(
'johndoe-eph123456', ['labels' => ['key2=value2']],
true
);

$request = $this->responses->getLastRequest();
$this->assertEquals('PUT', $request->getMethod());
$this->assertEquals('/v2/brancher/johndoe-eph123456/', $request->getUri());
$this->assertJson((string)$request->getBody());
$this->assertEquals(
['labels' => ['key2=value2', 'key1=value1']],
json_decode((string)$request->getBody(), true)
);
$this->assertEquals(
['labels' => [ 'key1' => 'value1', 'key2' => 'value2']],
$result
);
}

public function testUpdateBrancherAppRaisesClientExceptions()
{
$badRequestResponse = new Response(400, [], json_encode([
Expand Down

0 comments on commit e26d9ae

Please sign in to comment.