Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3749246
D221.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D221.diff
View Options
diff --git a/tests/Notifications/DockerHubNotificationTest.php b/tests/Notifications/DockerHubNotificationTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Notifications/DockerHubNotificationTest.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Notifications;
+
+use Nasqueron\Notifications\Notifications\DockerHubNotification;
+use Nasqueron\Notifications\Tests\TestCase;
+
+class DockerHubNotificationTest extends TestCase {
+ /**
+ * @var Nasqueron\Notifications\Notifications\DockerHubNotification
+ */
+ private $notification;
+
+ /**
+ * @var stdClass
+ */
+ private $payload;
+
+ public function setUp () {
+ $path = __DIR__ . '/../data/payloads/DockerHubPushPayload.json';
+ $this->payload = json_decode(file_get_contents($path));
+
+ $this->notification = new DockerHubNotification(
+ "Acme",
+ "push",
+ $this->payload
+ );
+ }
+
+ public function testProperties () {
+ $this->assertEquals("DockerHub", $this->notification->service);
+ $this->assertEquals("Acme", $this->notification->project);
+ $this->assertEquals("docker", $this->notification->group);
+ $this->assertEquals($this->payload, $this->notification->rawContent);
+ $this->assertEquals("push", $this->notification->type);
+ $this->assertEquals(
+ "New image pushed to Docker Hub registry for svendowideit/testhook by trustedbuilder",
+ $this->notification->text
+ );
+ $this->assertEquals(
+ "https://registry.hub.docker.com/u/svendowideit/testhook/",
+ $this->notification->link
+ );
+ }
+}
+
diff --git a/tests/data/payloads/DockerHubPushPayload.json b/tests/data/payloads/DockerHubPushPayload.json
new file mode 100644
--- /dev/null
+++ b/tests/data/payloads/DockerHubPushPayload.json
@@ -0,0 +1,28 @@
+{
+ "callback_url": "https://registry.hub.docker.com/u/svendowideit/testhook/hook/2141b5bi5i5b02bec211i4eeih0242eg11000a/",
+ "push_data": {
+ "images": [
+ "27d47432a69bca5f2700e4dff7de0388ed65f9d3fb1ec645e2bc24c223dc1cc3",
+ "51a9c7c1f8bb2fa19bcd09789a34e63f35abb80044bc10196e304f6634cc582c"
+ ],
+ "pushed_at": 1417566161,
+ "pusher": "trustedbuilder"
+ },
+ "repository": {
+ "comment_count": 0,
+ "date_created": 1417494799,
+ "description": "",
+ "dockerfile": "FROM golang:onbuild",
+ "full_description": "Docker Hub based automated build from a GitHub repo",
+ "is_official": false,
+ "is_private": true,
+ "is_trusted": true,
+ "name": "testhook",
+ "namespace": "svendowideit",
+ "owner": "svendowideit",
+ "repo_name": "svendowideit/testhook",
+ "repo_url": "https://registry.hub.docker.com/u/svendowideit/testhook/",
+ "star_count": 0,
+ "status": "Active"
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 13:53 (21 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2249459
Default Alt Text
D221.diff (2 KB)
Attached To
Mode
D221: Test DockerHubNotification
Attached
Detach File
Event Timeline
Log In to Comment