                           [:v4 "/v4/environments/foo/resources"]])
 
 (deftestseq unknown-parent-handling
-  [[version endpoint] no-parent-endpoints]
+  [[version endpoint] no-parent-endpoints
+   method [:get :post]]
 
-  (let [{:keys [status body]} (get-response endpoint)]
+  (let [{:keys [status body]} (query-response method endpoint)]
     (is (= status http/status-not-found))
     (is (= {:error "No information is known about environment foo"} (json/parse-string body true)))))

    (fixt/without-db-var
     (fn []
       (is (= {:name "foo"}
              (json/parse-string (:body (get-response (str endpoint "/foo")))
                                 true)))))))

(deftestseq environment-subqueries
  [[version endpoint] endpoints]

  (let [{:keys [web1 web2 db puppet]} (tu-nodes/store-example-nodes)]
    (doseq [env ["foo" "bar" "baz"]]
      (storage/ensure-environment env))

    (are [query expected] (= expected
                             (-> (:body (get-response endpoint query))
                                 (json/parse-string true)))

         ["in" "name"

            [puppetlabs.puppetdb.scf.storage :as storage]
            [clojure.test :refer :all]
            [puppetlabs.puppetdb.testutils :refer [get-request deftestseq]]
            [puppetlabs.puppetdb.testutils.http :refer [query-response
                                                        query-result
                                                        order-param]]
            [puppetlabs.puppetdb.testutils.nodes :as tu-nodes]))

(use-fixtures :each fixt/with-test-db fixt/with-http-app)

(def endpoints [[:v4 "/v4/environments"]])

;; TESTS

(deftestseq test-all-environments
  [[version endpoint] endpoints
   method [:get :post]]

  (testing "without environments"
    (is (empty? (query-result method endpoint))))

  (testing "with environments"
    (doseq [env ["foo" "bar" "baz"]]
