{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/comments/68326366","id":68326366,"diff_hunk":"@@ -0,0 +1,178 @@\n+(ns puppetlabs.puppetdb.http.producers-test\n+  (:require [puppetlabs.puppetdb.cheshire :as json]\n+            [puppetlabs.puppetdb.http :as http]\n+            [puppetlabs.puppetdb.scf.storage :as storage]\n+            [puppetlabs.puppetdb.query-eng :as eng]\n+            [clojure.test :refer :all]\n+            [puppetlabs.puppetdb.testutils.db :refer [without-db-var]]\n+            [puppetlabs.puppetdb.testutils.http :refer [deftest-http-app\n+                                                        query-response\n+                                                        query-result]]\n+            [puppetlabs.puppetdb.testutils.nodes :as tu-nodes]))\n+\n+(def endpoints [[:v4 \"/v4/producers\"]])\n+\n+(deftest-http-app test-all-producers\n+  [[version endpoint] endpoints\n+   method [:get :post]]\n+\n+  (testing \"without producers\"\n+    (is (empty? (query-result method endpoint))))\n+\n+  (testing \"with producers\"\n+    (doseq [prod [\"foo\" \"bar\" \"baz\"]]\n+      (storage/ensure-producer prod))\n+\n+    (without-db-var\n+     (fn []\n+       (is (= #{{:name \"foo\"}\n+                {:name \"bar\"}\n+                {:name \"baz\"}}\n+              (query-result method endpoint)))))\n+\n+    (without-db-var\n+     (fn []\n+       (let [res (query-response method endpoint)]\n+         (is (= #{{:name \"foo\"}\n+                  {:name \"bar\"}\n+                  {:name \"baz\"}}\n+                (set @(future (-> (query-response method endpoint)\n+                                  :body\n+                                  slurp\n+                                  (json/parse-string true)))))))))))\n+\n+(deftest-http-app test-query-producer\n+  [[version endpoint] endpoints\n+   method [:get :post]]\n+\n+  (testing \"without producers\"\n+    (without-db-var\n+     (fn []\n+       (is (= 404 (:status (query-response method (str endpoint \"/foo\"))))))))\n+\n+  (testing \"with producers\"\n+    (doseq [prod [\"foo\" \"bar\" \"baz\"]]\n+      (storage/ensure-producer prod))\n+    (without-db-var\n+     (fn []\n+       (is (= {:name \"foo\"}\n+              (-> (query-response method (str endpoint \"/foo\"))\n+                  :body\n+                  (json/parse-string true))))))))\n+\n+(deftest-http-app producer-queries\n+  [[version endpoint] endpoints\n+   method [:get :post]]\n+\n+  (let [{:keys [web1 web2 db puppet]} (tu-nodes/store-example-nodes)]\n+    ; (doseq [prod [\"foo\" \"bar\" \"baz\"]]\n+    ;   (storage/ensure-producer prod))","path":"test/puppetlabs/puppetdb/http/producers_test.clj","position":69,"original_position":69,"commit_id":"5090afdb3b696b79e4313a9d2ccd97fa52a27b4d","original_commit_id":"5090afdb3b696b79e4313a9d2ccd97fa52a27b4d","user":{"login":"mwaggett","id":7798734,"avatar_url":"https://avatars.githubusercontent.com/u/7798734?v=3","gravatar_id":"","url":"https://api.github.com/users/mwaggett","html_url":"https://github.com/mwaggett","followers_url":"https://api.github.com/users/mwaggett/followers","following_url":"https://api.github.com/users/mwaggett/following{/other_user}","gists_url":"https://api.github.com/users/mwaggett/gists{/gist_id}","starred_url":"https://api.github.com/users/mwaggett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwaggett/subscriptions","organizations_url":"https://api.github.com/users/mwaggett/orgs","repos_url":"https://api.github.com/users/mwaggett/repos","events_url":"https://api.github.com/users/mwaggett/events{/privacy}","received_events_url":"https://api.github.com/users/mwaggett/received_events","type":"User","site_admin":false},"body":"oops, a remnant of copy+paste. Fixing now. :)","created_at":"2016-06-23T22:23:51Z","updated_at":"2016-06-23T22:23:51Z","html_url":"https://github.com/puppetlabs/puppetdb/pull/1983#discussion_r68326366","pull_request_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/1983","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/comments/68326366"},"html":{"href":"https://github.com/puppetlabs/puppetdb/pull/1983#discussion_r68326366"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/1983"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/1983","id":74478534,"html_url":"https://github.com/puppetlabs/puppetdb/pull/1983","diff_url":"https://github.com/puppetlabs/puppetdb/pull/1983.diff","patch_url":"https://github.com/puppetlabs/puppetdb/pull/1983.patch","issue_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues/1983","number":1983,"state":"open","locked":false,"title":"(PDB-2782) Add \"producers\" as a queryable entity","user":{"login":"mwaggett","id":7798734,"avatar_url":"https://avatars.githubusercontent.com/u/7798734?v=3","gravatar_id":"","url":"https://api.github.com/users/mwaggett","html_url":"https://github.com/mwaggett","followers_url":"https://api.github.com/users/mwaggett/followers","following_url":"https://api.github.com/users/mwaggett/following{/other_user}","gists_url":"https://api.github.com/users/mwaggett/gists{/gist_id}","starred_url":"https://api.github.com/users/mwaggett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwaggett/subscriptions","organizations_url":"https://api.github.com/users/mwaggett/orgs","repos_url":"https://api.github.com/users/mwaggett/repos","events_url":"https://api.github.com/users/mwaggett/events{/privacy}","received_events_url":"https://api.github.com/users/mwaggett/received_events","type":"User","site_admin":false},"body":"This commit adds a \"producers\" query endpoint and includes reports, catalogs,\r\nand factsets as subquery endpoints.","created_at":"2016-06-20T17:08:54Z","updated_at":"2016-06-23T22:23:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c9643e17571ede3b9e64f5d0153274da9bc1114b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/1983/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/1983/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues/1983/comments","statuses_url":"https://api.github.com/repos/puppetlabs/puppetdb/statuses/5090afdb3b696b79e4313a9d2ccd97fa52a27b4d","head":{"label":"mwaggett:ticket/master/pdb-2782/producer_should_be_queryable_entity","ref":"ticket/master/pdb-2782/producer_should_be_queryable_entity","sha":"5090afdb3b696b79e4313a9d2ccd97fa52a27b4d","user":{"login":"mwaggett","id":7798734,"avatar_url":"https://avatars.githubusercontent.com/u/7798734?v=3","gravatar_id":"","url":"https://api.github.com/users/mwaggett","html_url":"https://github.com/mwaggett","followers_url":"https://api.github.com/users/mwaggett/followers","following_url":"https://api.github.com/users/mwaggett/following{/other_user}","gists_url":"https://api.github.com/users/mwaggett/gists{/gist_id}","starred_url":"https://api.github.com/users/mwaggett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwaggett/subscriptions","organizations_url":"https://api.github.com/users/mwaggett/orgs","repos_url":"https://api.github.com/users/mwaggett/repos","events_url":"https://api.github.com/users/mwaggett/events{/privacy}","received_events_url":"https://api.github.com/users/mwaggett/received_events","type":"User","site_admin":false},"repo":{"id":59525561,"name":"puppetdb","full_name":"mwaggett/puppetdb","owner":{"login":"mwaggett","id":7798734,"avatar_url":"https://avatars.githubusercontent.com/u/7798734?v=3","gravatar_id":"","url":"https://api.github.com/users/mwaggett","html_url":"https://github.com/mwaggett","followers_url":"https://api.github.com/users/mwaggett/followers","following_url":"https://api.github.com/users/mwaggett/following{/other_user}","gists_url":"https://api.github.com/users/mwaggett/gists{/gist_id}","starred_url":"https://api.github.com/users/mwaggett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwaggett/subscriptions","organizations_url":"https://api.github.com/users/mwaggett/orgs","repos_url":"https://api.github.com/users/mwaggett/repos","events_url":"https://api.github.com/users/mwaggett/events{/privacy}","received_events_url":"https://api.github.com/users/mwaggett/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mwaggett/puppetdb","description":"Centralized Puppet Storage","fork":true,"url":"https://api.github.com/repos/mwaggett/puppetdb","forks_url":"https://api.github.com/repos/mwaggett/puppetdb/forks","keys_url":"https://api.github.com/repos/mwaggett/puppetdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mwaggett/puppetdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mwaggett/puppetdb/teams","hooks_url":"https://api.github.com/repos/mwaggett/puppetdb/hooks","issue_events_url":"https://api.github.com/repos/mwaggett/puppetdb/issues/events{/number}","events_url":"https://api.github.com/repos/mwaggett/puppetdb/events","assignees_url":"https://api.github.com/repos/mwaggett/puppetdb/assignees{/user}","branches_url":"https://api.github.com/repos/mwaggett/puppetdb/branches{/branch}","tags_url":"https://api.github.com/repos/mwaggett/puppetdb/tags","blobs_url":"https://api.github.com/repos/mwaggett/puppetdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mwaggett/puppetdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mwaggett/puppetdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/mwaggett/puppetdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mwaggett/puppetdb/statuses/{sha}","languages_url":"https://api.github.com/repos/mwaggett/puppetdb/languages","stargazers_url":"https://api.github.com/repos/mwaggett/puppetdb/stargazers","contributors_url":"https://api.github.com/repos/mwaggett/puppetdb/contributors","subscribers_url":"https://api.github.com/repos/mwaggett/puppetdb/subscribers","subscription_url":"https://api.github.com/repos/mwaggett/puppetdb/subscription","commits_url":"https://api.github.com/repos/mwaggett/puppetdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/mwaggett/puppetdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/mwaggett/puppetdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/mwaggett/puppetdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/mwaggett/puppetdb/contents/{+path}","compare_url":"https://api.github.com/repos/mwaggett/puppetdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mwaggett/puppetdb/merges","archive_url":"https://api.github.com/repos/mwaggett/puppetdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mwaggett/puppetdb/downloads","issues_url":"https://api.github.com/repos/mwaggett/puppetdb/issues{/number}","pulls_url":"https://api.github.com/repos/mwaggett/puppetdb/pulls{/number}","milestones_url":"https://api.github.com/repos/mwaggett/puppetdb/milestones{/number}","notifications_url":"https://api.github.com/repos/mwaggett/puppetdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mwaggett/puppetdb/labels{/name}","releases_url":"https://api.github.com/repos/mwaggett/puppetdb/releases{/id}","deployments_url":"https://api.github.com/repos/mwaggett/puppetdb/deployments","created_at":"2016-05-23T23:35:43Z","updated_at":"2016-05-23T23:35:45Z","pushed_at":"2016-06-23T22:13:55Z","git_url":"git://github.com/mwaggett/puppetdb.git","ssh_url":"git@github.com:mwaggett/puppetdb.git","clone_url":"https://github.com/mwaggett/puppetdb.git","svn_url":"https://github.com/mwaggett/puppetdb","homepage":"http://docs.puppetlabs.com/puppetdb","size":17154,"stargazers_count":0,"watchers_count":0,"language":"Clojure","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"puppetlabs:master","ref":"master","sha":"38bd4716825d69514d2355b12c905631c2ba1d1e","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":2193032,"name":"puppetdb","full_name":"puppetlabs/puppetdb","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/puppetdb","description":"Centralized Puppet Storage","fork":false,"url":"https://api.github.com/repos/puppetlabs/puppetdb","forks_url":"https://api.github.com/repos/puppetlabs/puppetdb/forks","keys_url":"https://api.github.com/repos/puppetlabs/puppetdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/puppetdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/puppetdb/teams","hooks_url":"https://api.github.com/repos/puppetlabs/puppetdb/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/puppetdb/events","assignees_url":"https://api.github.com/repos/puppetlabs/puppetdb/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/puppetdb/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/puppetdb/tags","blobs_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/puppetdb/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/puppetdb/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/puppetdb/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/puppetdb/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/puppetdb/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/puppetdb/subscription","commits_url":"https://api.github.com/repos/puppetlabs/puppetdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/puppetdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/puppetdb/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/puppetdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/puppetdb/merges","archive_url":"https://api.github.com/repos/puppetlabs/puppetdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/puppetdb/downloads","issues_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/puppetdb/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/puppetdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/puppetdb/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/puppetdb/releases{/id}","deployments_url":"https://api.github.com/repos/puppetlabs/puppetdb/deployments","created_at":"2011-08-11T18:54:46Z","updated_at":"2016-05-29T22:34:37Z","pushed_at":"2016-06-23T22:13:56Z","git_url":"git://github.com/puppetlabs/puppetdb.git","ssh_url":"git@github.com:puppetlabs/puppetdb.git","clone_url":"https://github.com/puppetlabs/puppetdb.git","svn_url":"https://github.com/puppetlabs/puppetdb","homepage":"http://docs.puppetlabs.com/puppetdb","size":20862,"stargazers_count":190,"watchers_count":190,"language":"Clojure","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":155,"mirror_url":null,"open_issues_count":4,"forks":155,"open_issues":4,"watchers":190,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/1983"},"html":{"href":"https://github.com/puppetlabs/puppetdb/pull/1983"},"issue":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/issues/1983"},"comments":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/issues/1983/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/1983/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/1983/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/statuses/5090afdb3b696b79e4313a9d2ccd97fa52a27b4d"}}}}
{"actor":{"display_login":"mwaggett"}}