                              :timestamp reference-time
                              :producer producer})
             (testing "should have only the new facts"
-              (is (= (query-to-vec
-                      "SELECT fp.path as name,
-                              COALESCE(f.value_string,
-                                       cast(f.value_integer as text),
-                                       cast(f.value_boolean as text),
-                                       cast(f.value_float as text),
-                                       '') as value
-                       FROM factsets fs
-                         INNER JOIN facts as f on fs.id = f.factset_id
-                         INNER JOIN fact_paths as fp on f.fact_path_id = fp.id
-                       WHERE fp.depth = 0
-                       ORDER BY name")
-                     [{:name "domain" :value "mynewdomain.com"}
-                      {:name "fqdn" :value "myhost.mynewdomain.com"}
-                      {:name "hostname" :value "myhost"}
-                      {:name "kernel" :value "Linux"}
-                      {:name "uptime_seconds" :value "3600"}])))
+              (is (= new-facts (factset-map certname))))
             (testing "producer_timestamp should store current time"
               (is (= (query-to-vec "SELECT producer_timestamp FROM factsets")
                      [{:producer_timestamp (to-timestamp reference-time)}])))
             (testing "should update existing keys"
               (is (some #{{:timestamp (to-timestamp reference-time)
                            :environment_id 1
-                           :hash "cf56e1d01b3517d26f875855da4459ce19f8cd18"
+                           :hash "1a4b10a865b8c7b435ec0fe06968fdc62337f57f"
                            :producer_timestamp (to-timestamp reference-time)
                            :producer_id 1}}
                         ;; Again we grab the pertinent non-id bits

    (testing "creates new row for non-existing producer"
      (is (= 2 (ensure-producer prod2))))))

(defn-validated factset-map :- {s/Str s/Str}
  "Return all facts and their values for a given certname as a map"
  [certname :- String]
  (let [result (jdbc/query
                ["SELECT fp.path as name,
                    COALESCE(f.value_string,
                             cast(f.value_integer as text),
                             cast(f.value_boolean as text),
                             cast(f.value_float as text),
                             '') as value
                    FROM factsets fs
                    INNER JOIN facts as f on fs.id = f.factset_id
                    INNER JOIN fact_paths as fp on f.fact_path_id = fp.id
                    WHERE fp.depth = 0 AND fs.certname = ?"
                 certname])]
    (zipmap (map :name result)
            (map :value result))))

(deftest-db large-fact-update
  (testing "updating lots of facts"

                           "fqdn" "myhost.mynewdomain.com"
                           "hostname" "myhost"
                           "kernel" "Linux"
                           "uptime_seconds" 3600}]
            (replace-facts! {:certname certname
                             :values new-facts
                             :environment "DEV"
