Swirrl / drafter

A clojure service and a client to it for exposing data management operations to PMD
Other
0 stars 0 forks source link

Refactor data tests to cover all supported content types #656

Open lkitching opened 1 year ago

lkitching commented 1 year ago

The draftset data endpoints support uploading or requesting data in various content types. However, many of the tests only test these routes with a single content type, either directly or by using a test hepler function which hard-codes the content type. See for example get-draftset-quads-data which fetches the data using the get-user-draftset-quads-through-api hepler, which specifies the n-quads content type.

It should be possible to test all supported content types within each of these tests by refactoring the tests and helpers to be parameterised by content type and looping over all supported media types e.g.

(t/deftest get-draftset-quads-data
  ;; create draft and append data
  (doseq [format conneg/show-data-formats]
    (t/testing (str "Get data in format: " format)
      (let [quads (help/get-user-draftset-quads-through-api hander draftest test-editor format)
             expected ...]
        (t/is (= (set quads) (set expected)))))))