         tag2 (util/create-and-save-tag 2 2)]
     (testing "find latest revsions"
       (are3 [tags params]
-            (= (set tags)
+        (is (= (set tags)
                (set (->> (util/find-latest-concepts :tag params)
                          :concepts
-                         (map #(dissoc % :provider-id :revision-date :transaction-id)))))
-            "with metadata"
-            [tag1 tag2] {}
-
-            "exclude metadata"
-            [(dissoc tag1 :metadata) (dissoc tag2 :metadata)] {:exclude-metadata true}))
+                         (map #(dissoc % :provider-id :revision-date :transaction-id))))))
+        "with metadata"
+        [tag1 tag2] {}
+
+        "exclude metadata"
+        [(dissoc tag1 :metadata) (dissoc tag2 :metadata)] {:exclude-metadata true}))
 
     (testing "find all revisions"
       (let [num-of-tags (-> (util/find-concepts :tag)

                                                             :short-name "s7"}})]
    (testing "find-with-parameters"
      (are3 [collections params]
            (= (set collections)
               (set (-> (util/find-concepts :collection params)
                        :concepts
                        concepts-for-comparison)))
            "regular provider - provider-id"
            [coll1 coll2-2 coll5-2] {:provider-id "REG_PROV" :latest true}

            "small provider with tombstones - provider-id"
            [coll3 coll6-2] {:provider-id "SMAL_PROV1" :latest true}

            "small provider - provider-id"
            [coll4-3] {:provider-id "SMAL_PROV2" :latest true}

            "regular provider - provider-id, entry-title"
            [coll1] {:provider-id "REG_PROV" :entry-title "et1" :latest true}

            "small provider - provider-id, entry-title"
            [coll3] {:provider-id "SMAL_PROV1" :entry-title "et3" :latest true}

            "regular provider - provider-id, entry-id"
            [coll2-2] {:provider-id "REG_PROV" :entry-id "entry-2" :latest true}

            "small provider - provider-id, entry-id"
            [coll4-3] {:provider-id "SMAL_PROV2" :entry-id "entry-1" :latest true}

            "regular provider - short-name, version-id"
            [coll2-2] {:short-name "s2" :version-id "v2" :latest true}

            "small provider - short-name, version-id"
            [coll4-3] {:short-name "s4" :version-id "v5" :latest true}

            "small provider - match multiple - version-id"
            [coll3] {:version-id "v3" :latest true}

            ;; This test verifies that the provider-id is being used with the small_providers
            ;; table. Otherwise we would get both coll3 and coll4 back (see previous test).
            "small provider - provider-id, version-id"
            [coll4-3] {:provider-id "SMAL_PROV2" :version-id "v5" :latest true}

            "mixed providers - entry-title"
            [coll1 coll4-3] {:entry-title "et1" :latest true}

            "exclude-metadata=true"
            [(dissoc coll3 :metadata)]
            {:provider-id "SMAL_PROV1" :entry-id "entry-3" :exclude-metadata "true" :latest true}

            "exclude-metadata=false"
            [coll3]
            {:provider-id "SMAL_PROV1" :entry-id "entry-3" :exclude-metadata "false" :latest true}

            "regular provider - concept-id"
            [coll1] {:concept-id (:concept-id coll1) :latest true}

            "small provider - concept-id"
            [coll4-3] {:concept-id (:concept-id coll4-1) :latest true}

            "concept-id and version-id - latest"
            [coll4-3] {:concept-id (:concept-id coll4-1) :version-id "v5" :latest true}

            "find none - bad provider-id"
            [] {:provider-id "PROV_NONE" :latest true}

            "find none - provider-id, bad version-id"
            [] {:provider-id "REG_PROV" :version-id "v7" :latest true}

            ;; all revisions
            "provider-id - all revisions"
            [coll4-1 coll4-2 coll4-3] {:provider-id "SMAL_PROV2"}

            "entry-title - all revisions"
            [coll2-1 coll2-2] {:entry-title "et2"}

            "entry-title - all revisions - find latest false"
            [coll2-1 coll2-2] {:entry-title "et2" :latest false}

            "concept-id - all revisions"
            [coll4-1 coll4-2 coll4-3] {:concept-id (:concept-id coll4-1)}

            "concept-id and version-id - all revisions"
            [coll4-1] {:concept-id (:concept-id coll4-1) :version-id "v3"}

            "params containing a vector are ORed"
            [coll1 coll3 coll4-3] {:entry-title ["et1" "et3"] :latest true}

            "multiple ORed param lists are ANDed together"
            [coll3] {:entry-title ["et1" "et3"] :short-name ["s3" "s5"] :latest true}))))

(deftest get-expired-collections-concept-ids
  (let [time-now (tk/now)

    (testing "find with parameters"
      (testing "latest revisions"
        (are3 [groups params]
          (is (= (set (map util/expected-concept groups))
                 (set (-> (util/find-latest-concepts :access-group params)
                          :concepts
                          concepts-for-comparison))))
          ;; These are the only valid combinations for groups
          "provider-id, native-id"
          [group1] {:provider-id "REG_PROV" :native-id "native-id 1"}

          "no metadata"
          [(dissoc group1 :metadata)] {:provider-id "REG_PROV"
                                       :exclude-metadata true}))

      (testing "all revisions"
        (are3 [rev-count params]
          (= rev-count
             (count (-> (util/find-concepts :access-group params)
                        :concepts)))
          "provider-id, native-id - three revisons"
          3 {:provider-id "REG_PROV" :native-id "native-id 1"}
          "everything"
          5 {})))))

(deftest find-variables
  (let [;; create two variables with the same native-id on different providers with multiple revisions
         variable1 (util/create-and-save-variable "REG_PROV" 1 3)
         variable2 (util/create-and-save-variable "SMAL_PROV1" 1 2)]
    (testing "find latest revsions"
      (are3 [variables params]
        (is (= (set variables)
               (set (->> (util/find-latest-concepts :variable params)
                         :concepts
                         concepts-for-comparison))))

        "with metadata search by provider-id"
        [variable1] {:provider-id "REG_PROV"}

        "with metadata search by concept-id"
        [variable1] {:concept-id (:concept-id variable1)}

        "with metadata search by native-id"
        [variable1 variable2] {:native-id (:native-id variable1)}

        "with metadata search by provider-id and native-id"
        [variable2] {:provider-id "SMAL_PROV1"
                     :native-id (:native-id variable1)}

        "exclude metadata search by concept-id"
        [(dissoc variable1 :metadata)] {:concept-id (:concept-id variable1)
                                        :exclude-metadata true}

        "exclude metadata search by provider-id and native-id"
        [(dissoc variable2 :metadata)] {:provider-id "SMAL_PROV1"
                                        :native-id (:native-id variable1)
                                        :exclude-metadata true}

        "no match by native id"
        [] {:native-id "foo"}

        "no match by provider-id"
        []
        {:provider-id "PROV_NONE"}))

    (testing "find all revisions"
      (let [num-of-variables (-> :variable
                                 (util/find-concepts {:native-id (:native-id variable1)})
                                 :concepts
                                 count)]
        (is (= 5 num-of-variables))))))
