diff --git a/server/test/instant/admin/routes_test.clj b/server/test/instant/admin/routes_test.clj index a21a35a82..fc06b677e 100644 --- a/server/test/instant/admin/routes_test.clj +++ b/server/test/instant/admin/routes_test.clj @@ -659,8 +659,7 @@ first (get "name"))))) (testing "create link attrs" - (let [pref-id (str (random-uuid)) - stopa-id (-> (query-post + (let [stopa-id (-> (query-post {:body {:query {:users {:$ {:where {:handle "stopa"}}}}} :headers {"app-id" (str app-id) "authorization" (str "Bearer " admin-token)}}) diff --git a/server/test/instant/db/datalog_test.clj b/server/test/instant/db/datalog_test.clj index 1ab5b9b9d..4b9b19a99 100644 --- a/server/test/instant/db/datalog_test.clj +++ b/server/test/instant/db/datalog_test.clj @@ -6,8 +6,7 @@ [instant.data.constants :refer [movies-app-id]] [instant.data.resolvers :as resolvers] [instant.jdbc.sql :as sql] - [instant.fixtures :refer [with-zeneca-app]] - [instant.db.model.attr :as attr-model])) + [instant.fixtures :refer [with-zeneca-app]])) (def ^:private r (delay (resolvers/make-movies-resolver))) diff --git a/server/test/instant/db/indexing_jobs_test.clj b/server/test/instant/db/indexing_jobs_test.clj index f3aaba0c0..7bfe7e17c 100644 --- a/server/test/instant/db/indexing_jobs_test.clj +++ b/server/test/instant/db/indexing_jobs_test.clj @@ -81,7 +81,7 @@ (= checked-data-type "number"))) order-triples)) - (is (every? (fn [{:keys [triple checked-data-type]}] + (is (every? (fn [{:keys [checked-data-type]}] (= checked-data-type "date")) created-at-triples)) @@ -186,11 +186,7 @@ (with-indexing-job-queue job-queue (with-zeneca-app-no-indexing (fn [app r] - (let [title-triples-before (triple-model/fetch (aurora/conn-pool :read) - (:id app) - [[:= :attr-id (resolvers/->uuid r :books/title)]]) - - title-job (jobs/create-index-job! + (let [title-job (jobs/create-index-job! {:app-id (:id app) :attr-id (resolvers/->uuid r :books/title)}) diff --git a/server/test/instant/db/instaql_test.clj b/server/test/instant/db/instaql_test.clj index a5a121647..43bedabef 100644 --- a/server/test/instant/db/instaql_test.clj +++ b/server/test/instant/db/instaql_test.clj @@ -1964,7 +1964,7 @@ (deftest where-$not-$isNull-with-links-1-to-1 (with-empty-app (fn [app] - (let [{:keys [r add-links clear-links admin-query]} + (let [{:keys [add-links admin-query]} (add-references-to-app app :one :one)] @@ -2040,7 +2040,7 @@ (deftest where-$not-$isNull-with-links-1-to-many (with-empty-app (fn [app] - (let [{:keys [r add-links clear-links admin-query]} + (let [{:keys [add-links admin-query]} (add-references-to-app app :one :many)] @@ -2117,7 +2117,7 @@ (deftest where-$not-$isNull-with-links-many-to-1 (with-empty-app (fn [app] - (let [{:keys [r add-links clear-links admin-query]} + (let [{:keys [add-links admin-query]} (add-references-to-app app :many :one)] @@ -2194,7 +2194,7 @@ (deftest where-$not-$isNull-with-links-many-to-many (with-empty-app (fn [app] - (let [{:keys [r add-links clear-links admin-query]} + (let [{:keys [add-links admin-query]} (add-references-to-app app :many :one)] @@ -2532,11 +2532,7 @@ :app-id (:id app) :attrs attrs})) run-query (fn [return-field q] - (let [ctx (make-ctx) - r (resolvers/make-resolver {:conn-pool (aurora/conn-pool :read)} - (:id app) - [["books" "field"] - ["authors" "field"]])] + (let [ctx (make-ctx)] (->> (iq/permissioned-query ctx q) (instaql-nodes->object-tree ctx) (#(get % "etype")) @@ -2677,10 +2673,10 @@ :cardinality :one}]] (let [id (random-uuid)] [[:add-triple id (:id attr-ids) (str id)] - [:add-triple id (:handle attr-ids) (str "a")]]) + [:add-triple id (:handle attr-ids) "a"]]) (let [id (random-uuid)] [[:add-triple id (:id attr-ids) (str id)] - [:add-triple id (:handle attr-ids) (str "b")]])))] + [:add-triple id (:handle attr-ids) "b"]])))] (sql/select (aurora/conn-pool :write) ["ANALYZE triples"]) (testing "query on unique attr" (let [{:keys [patterns]} (iq/instaql-query->patterns @@ -2832,7 +2828,7 @@ (deftest nested-order-by (with-zeneca-checked-data-app - (fn [app r] + (fn [app _r] (let [ctx {:db {:conn-pool (aurora/conn-pool :read)} :app-id (:id app) :attrs (attr-model/get-by-app-id (:id app))}] @@ -2863,7 +2859,7 @@ (deftest order-by-with-ors-and-ands (with-zeneca-checked-data-app - (fn [app r] + (fn [app _r] (let [ctx {:db {:conn-pool (aurora/conn-pool :read)} :app-id (:id app) :attrs (attr-model/get-by-app-id (:id app))}] @@ -3727,11 +3723,7 @@ {:db {:conn-pool (aurora/conn-pool :read)} :app-id (:id app) :attrs attrs - :admin? admin?}) - r (resolvers/make-resolver {:conn-pool (aurora/conn-pool :read)} - (:id app) - [["books" "field"] - ["authors" "field"]])] + :admin? admin?})] (->> (iq/permissioned-query ctx q) (instaql-nodes->object-tree ctx))))] (tx/transact! (aurora/conn-pool :write) diff --git a/server/test/instant/db/transaction_test.clj b/server/test/instant/db/transaction_test.clj index 3676b5cf5..ea0cac156 100644 --- a/server/test/instant/db/transaction_test.clj +++ b/server/test/instant/db/transaction_test.clj @@ -1,6 +1,5 @@ (ns instant.db.transaction-test (:require - [clojure.set :as set] [clojure.string :as string] [clojure.test :as test :refer [are deftest is testing]] [instant.db.cel :as cel] @@ -13,7 +12,6 @@ [instant.db.model.triple :as triple-model] [instant.db.permissioned-transaction :as permissioned-tx] [instant.db.transaction :as tx] - [instant.db.indexing-jobs :as indexing-jobs] [instant.fixtures :refer [with-empty-app with-zeneca-app with-zeneca-app-no-indexing]] @@ -21,7 +19,6 @@ [instant.model.app :as app-model] [instant.model.app-user :as app-user-model] [instant.model.rule :as rule-model] - [instant.util.coll :as coll] [instant.util.instaql :refer [instaql-nodes->object-tree]] [instant.util.exception :as ex] [instant.util.test :as test-util :refer [suid]]) @@ -1536,7 +1533,7 @@ (deftest new-indexed-blobs-get-nulls (with-zeneca-app - (fn [app r] + (fn [app _r] (let [make-ctx (fn [] {:db {:conn-pool (aurora/conn-pool :write)} :app-id (:id app) :attrs (attr-model/get-by-app-id (:id app)) @@ -2326,8 +2323,7 @@ (deftest perms-accepts-writes-to-reverse-links-to-users-table (with-empty-app (fn [{app-id :id}] - (let [r (resolvers/make-movies-resolver app-id) - book-id-attr-id (random-uuid) + (let [book-id-attr-id (random-uuid) book-creator-attr-id (random-uuid) book-id (random-uuid) user-id (random-uuid) @@ -2447,7 +2443,7 @@ (deftest auth-refs-requires-users (with-empty-app - (fn [{app-id :id :as app}] + (fn [_app] (testing "auth.ref requires $users namespace" (is (= [] (rule-model/validation-errors @@ -2461,8 +2457,7 @@ (deftest users-write-perms (with-empty-app (fn [{app-id :id}] - (let [r (resolvers/make-movies-resolver app-id) - book-id-attr-id (random-uuid) + (let [book-id-attr-id (random-uuid) book-creator-attr-id (random-uuid) book-isbn-attr-id (random-uuid) book-title-attr-id (random-uuid) @@ -2703,8 +2698,7 @@ [[:users/email :unique? :index?] [[:users/friend :users/friend-of] :unique? :on-delete]]) ids #{(suid "1") (suid "2")} - ctx (test-util/make-ctx app-id {:rw :write}) - attr-model (attr-model/get-by-app-id app-id)] + ctx (test-util/make-ctx app-id {:rw :write})] (test-util/insert-entities app-id attr->id @@ -2722,24 +2716,24 @@ (fn [{app-id :id}] (let [user-id-attr-id (random-uuid) user-parent-attr-id (random-uuid) - insert-res (attr-model/insert-multi! - (aurora/conn-pool :write) - app-id - [{:id user-id-attr-id - :forward-identity [(random-uuid) "users" "id"] - :value-type :blob - :cardinality :one - :unique? true - :index? true} - {:id user-parent-attr-id - :forward-identity [(random-uuid) "users" "parent"] - :reverse-identity [(random-uuid) "users" "children"] - :value-type :ref - :cardinality :one - :unique? false - :index? false - :on-delete :cascade}] - {}) + _ (attr-model/insert-multi! + (aurora/conn-pool :write) + app-id + [{:id user-id-attr-id + :forward-identity [(random-uuid) "users" "id"] + :value-type :blob + :cardinality :one + :unique? true + :index? true} + {:id user-parent-attr-id + :forward-identity [(random-uuid) "users" "parent"] + :reverse-identity [(random-uuid) "users" "children"] + :value-type :ref + :cardinality :one + :unique? false + :index? false + :on-delete :cascade}] + {}) root-user-id (random-uuid) children (atom 0)] @@ -2764,8 +2758,7 @@ (swap! children + (/ (count tx) 2)) (recur (inc i) (into #{} (map second tx)))))) - (let [t0 (System/nanoTime) - ctx {:db {:conn-pool (aurora/conn-pool :write)} + (let [ctx {:db {:conn-pool (aurora/conn-pool :write)} :app-id app-id :attrs (attr-model/get-by-app-id app-id) :datalog-query-fn d/query @@ -2773,9 +2766,5 @@ :current-user nil} tx-steps [[:delete-entity root-user-id "users"]] res (permissioned-tx/transact! ctx tx-steps) - dt (-> (System/nanoTime) (- t0) (/ 1000000.0)) deleted-triples (count (:delete-entity (:results res)))] - (is (= (-> @children (* 2) (+ 1)) deleted-triples)) - #_(is (< dt 500))))))) -(comment - (test/run-tests *ns*)) + (is (= (-> @children (* 2) (+ 1)) deleted-triples))))))) diff --git a/server/test/instant/jdbc/sql_test.clj b/server/test/instant/jdbc/sql_test.clj index 78d160eb7..c2a70450b 100644 --- a/server/test/instant/jdbc/sql_test.clj +++ b/server/test/instant/jdbc/sql_test.clj @@ -31,8 +31,8 @@ (deftest in-progress-removes-itself-on-query-completion (let [in-progress (sql/make-statement-tracker)] (binding [sql/*in-progress-stmts* in-progress] - (let [query (sql/select (aurora/conn-pool :read) ["select 1"])] - (is (= 0 (count @(:stmts in-progress)))))))) + (sql/select (aurora/conn-pool :read) ["select 1"]) + (is (= 0 (count @(:stmts in-progress))))))) (deftest cant-write-on-a-readonly-connection (is (thrown-with-msg? clojure.lang.ExceptionInfo diff --git a/server/test/instant/reactive/invalidator_test.clj b/server/test/instant/reactive/invalidator_test.clj index 695247433..1f568c8ea 100644 --- a/server/test/instant/reactive/invalidator_test.clj +++ b/server/test/instant/reactive/invalidator_test.clj @@ -1,6 +1,5 @@ (ns instant.reactive.invalidator-test (:require - [clojure.core.async :as a] [clojure.string :as string] [clojure.test :as test :refer [deftest testing is]] [instant.data.resolvers :as resolvers] @@ -401,7 +400,7 @@ #"-" "_")] (with-redefs [inv/invalidate! - (fn [process-id store-conn {:keys [app-id tx-id] :as wal-record}] + (fn [process-id store-conn {:keys [app-id] :as wal-record}] (if (and (= machine-id process-id) (= (:id app) app-id)) (swap! records conj wal-record) (invalidate! store-conn wal-record)))] diff --git a/server/test/instant/reactive/session_test.clj b/server/test/instant/reactive/session_test.clj index 34da1f33a..b378a3570 100644 --- a/server/test/instant/reactive/session_test.clj +++ b/server/test/instant/reactive/session_test.clj @@ -10,7 +10,6 @@ [instant.db.instaql :as iq] [instant.db.model.attr :as attr-model] [instant.db.transaction :as tx] - [instant.flags :as flags] [instant.fixtures :refer [with-empty-app with-movies-app]] [instant.grouped-queue :as grouped-queue] [instant.jdbc.aurora :as aurora] @@ -23,7 +22,7 @@ [instant.util.async :as ua] [instant.util.coll :as ucoll]) (:import - (com.hazelcast.core Hazelcast HazelcastInstance) + (com.hazelcast.core HazelcastInstance) (java.util UUID))) (test/use-fixtures :each @@ -102,14 +101,14 @@ (defn read-msg [{:keys [ws-conn id]}] (let [ret (ua/