forgot a few

This commit is contained in:
Gered 2016-05-31 18:32:59 -04:00
parent aec0ccfe41
commit cbeae300d9

View file

@ -21,28 +21,28 @@
(deftest vexec-runs-query-and-puts-hints
(let [sqlvec ["INSERT INTO example (field1, field2, field3) VALUES ('test', 'N', NULL)"]
result (vexec! test-view-system test-db sqlvec)]
(is (= [test-db sqlvec] (:jdbc/execute! @redefs-called)))
(is (called-with-args? :jdbc/execute! test-db sqlvec))
(is (= :jdbc/execute!-return-value result))
(is (called-with-args? :views/put-hints! test-view-system [(views/hint nil #{:example} hint-type)]))))
(deftest vexec-runs-query-with-returning-clause
(let [sqlvec ["INSERT INTO example (field1, field2, field3) VALUES ('test', 'N', NULL) RETURNING *"]
result (vexec! test-view-system test-db sqlvec)]
(is (= [test-db sqlvec] (:jdbc/query @redefs-called)))
(is (called-with-args? :jdbc/query test-db sqlvec))
(is (= :jdbc/query-return-value result))
(is (called-with-args? :views/put-hints! test-view-system [(views/hint nil #{:example} hint-type)]))))
(deftest namespace-is-passed-along-to-hints-via-vexec
(let [sqlvec ["INSERT INTO example (field1, field2, field3) VALUES ('test', 'N', NULL)"]
result (vexec! test-view-system test-db sqlvec {:namespace :foobar})]
(is (= [test-db sqlvec] (:jdbc/execute! @redefs-called)))
(is (called-with-args? :jdbc/execute! test-db sqlvec))
(is (= :jdbc/execute!-return-value result))
(is (called-with-args? :views/put-hints! test-view-system [(views/hint :foobar #{:example} hint-type)]))))
(deftest manually-provided-hints-to-vexec-are-passed-to-views-system
(let [sqlvec ["INSERT INTO example (field1, field2, field3) VALUES ('test', 'N', NULL)"]
result (vexec! test-view-system test-db sqlvec [:foo :bar])]
(is (= [test-db sqlvec] (:jdbc/execute! @redefs-called)))
(is (called-with-args? :jdbc/execute! test-db sqlvec))
(is (= :jdbc/execute!-return-value result))
(is (called-with-args? :views/put-hints! test-view-system [(views/hint nil #{:foo :bar} hint-type)]))))
@ -51,7 +51,7 @@
result (vexec! test-view-system test-db sqlvec [:foo :bar])]
; means jdbc/execute! was called which is correct behaviour since the returning option was not specified.
; if jdbc/execute! was really called it would throw an exception since the INSERT query used has a RETURNING clause
(is (= [test-db sqlvec] (:jdbc/execute! @redefs-called)))
(is (called-with-args? :jdbc/execute! test-db sqlvec))
(is (= :jdbc/execute!-return-value result))
(is (called-with-args? :views/put-hints! test-view-system [(views/hint nil #{:foo :bar} hint-type)])))
; manually reset some things
@ -59,6 +59,6 @@
(reset! query-info-cache {})
(let [sqlvec ["INSERT INTO example (field1, field2, field3) VALUES ('test', 'N', NULL) RETURNING *"]
result (vexec! test-view-system test-db sqlvec [:foo :bar] {:returning? true})]
(is (= [test-db sqlvec] (:jdbc/query @redefs-called)))
(is (called-with-args? :jdbc/query test-db sqlvec))
(is (= :jdbc/query-return-value result))
(is (called-with-args? :views/put-hints! test-view-system [(views/hint nil #{:foo :bar} hint-type)]))))