-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from groundedSAGE/update-cljs-support2
Updates clojurescript support for memory store
- Loading branch information
Showing
12 changed files
with
167 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,11 @@ pom.xml.asc | |
/.nrepl-port | ||
/.repl* | ||
out | ||
.shadow-cljs | ||
.cpcache | ||
.calva | ||
node_modules | ||
public | ||
|
||
.idea | ||
*.iml | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
clojure -A:test -m kaocha.runner "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{:paths ["src"] | ||
:deps {org.clojure/clojure {:mvn/version "1.10.1"} | ||
org.clojure/clojurescript {:mvn/version "1.10.764"} | ||
io.replikativ/incognito {:mvn/version "0.2.5"} | ||
io.replikativ/superv.async {:mvn/version "0.2.9-SNAPSHOT"} | ||
fress {:mvn/version "0.3.1"} | ||
org.clojure/data.fressian {:mvn/version "0.2.1"} ;; for filestore | ||
io.replikativ/hasch {:mvn/version "0.3.7"} | ||
org.clojars.mmb90/cljs-cache {:mvn/version "0.1.4"} | ||
org.lz4/lz4-java {:mvn/version "1.6.0"} | ||
com.taoensso/timbre {:mvn/version "4.10.0"}} | ||
:aliases {:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.10.21"} | ||
binaryage/devtools {:mvn/version "1.0.2"}} | ||
:extra-paths ["test"]} | ||
:dev {:extra-deps {criterium {:mvn/version "0.4.4"}}} | ||
:test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.0.641"} | ||
org.clojure/test.check {:mvn/version "0.9.0"}} | ||
:extra-paths ["test"]}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{:deps {:aliases [:cljs]} | ||
|
||
:builds | ||
{:app | ||
{:target :browser | ||
:output-dir "public/js" | ||
:asset-path "/js" | ||
:modules {:main {:entries [konserve.core]}}} | ||
|
||
:browser-test | ||
{:target :browser-test | ||
:test-dir "resources/public/js/test" | ||
:devtools {:http-port 8021 | ||
:http-root "resources/public/js/test"}} | ||
|
||
:node-test | ||
{:target :node-test | ||
:output-to "out/node-tests.js" | ||
:autorun true}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
(ns konserve.compliance-test | ||
(:refer-clojure :exclude [get get-in update update-in assoc assoc-in dissoc exists? keys]) | ||
(:require [clojure.core.async :as async :refer [#?(:clj <!!) go chan <!]] | ||
[konserve.core :refer [get assoc assoc-in get-in update-in dissoc bassoc bget keys get-meta exists?]] | ||
#?(:cljs [cljs.test :refer [deftest is testing async]]) | ||
#?(:clj [clojure.test :refer :all]) | ||
[konserve.memory :refer [new-mem-store]])) | ||
|
||
(deftype UnknownType []) | ||
|
||
#?(:clj (defn exception? [thing] | ||
(instance? Throwable thing))) | ||
|
||
#?(:clj | ||
(defn compliance-test [store] | ||
(testing "Test the core API." | ||
(is (= (<!! (get store :foo)) | ||
nil)) | ||
(<!! (assoc store :foo :bar)) | ||
(is (= (<!! (get store :foo)) | ||
:bar)) | ||
(<!! (assoc-in store [:foo] :bar2)) | ||
(is (= :bar2 (<!! (get store :foo)))) | ||
(is (= :default | ||
(<!! (get-in store [:fuu] :default)))) | ||
(is (= :bar2 (<!! (get store :foo)))) | ||
(is (= :default | ||
(<!! (get-in store [:fuu] :default)))) | ||
(<!! (update-in store [:foo] name)) | ||
(is (= "bar2" | ||
(<!! (get store :foo)))) | ||
(<!! (assoc-in store [:baz] {:bar 42})) | ||
(is (= (<!! (get-in store [:baz :bar])) | ||
42)) | ||
(<!! (update-in store [:baz :bar] inc)) | ||
(is (= (<!! (get-in store [:baz :bar])) | ||
43)) | ||
(<!! (update-in store [:baz :bar] + 2 3)) | ||
(is (= (<!! (get-in store [:baz :bar])) | ||
48)) | ||
(<!! (dissoc store :foo)) | ||
(is (= (<!! (get-in store [:foo])) | ||
nil)) | ||
(<!! (bassoc store :binbar (byte-array (range 10)))) | ||
(<!! (bget store :binbar (fn [{:keys [input-stream]}] | ||
(go | ||
(is (= (map byte (slurp input-stream)) | ||
(range 10))))))) | ||
(let [list-keys (<!! (keys store))] | ||
(are [x y] (= x y) | ||
#{{:key :baz | ||
:type :edn} | ||
{:key :binbar | ||
:type :binary}} | ||
(->> list-keys (map #(clojure.core/dissoc % :konserve.core/timestamp)) set) | ||
true | ||
(every? | ||
(fn [{:keys [:konserve.core/timestamp]}] | ||
(= (type (java.util.Date.)) (type timestamp))) | ||
list-keys))) | ||
|
||
(let [params (clojure.core/keys store) | ||
corruptor (fn [s k] | ||
(if (= (type (k s)) clojure.lang.Atom) | ||
(clojure.core/assoc-in s [k] (atom {})) | ||
(clojure.core/assoc-in s [k] (UnknownType.)))) | ||
corrupt (reduce corruptor store params)] | ||
(is (exception? (<!! (get corrupt :bad)))) | ||
(is (exception? (<!! (get-meta corrupt :bad)))) | ||
(is (exception? (<!! (assoc corrupt :bad 10)))) | ||
(is (exception? (<!! (dissoc corrupt :bad)))) | ||
(is (exception? (<!! (assoc-in corrupt [:bad :robot] 10)))) | ||
(is (exception? (<!! (update-in corrupt [:bad :robot] inc)))) | ||
(is (exception? (<!! (exists? corrupt :bad)))) | ||
(is (exception? (<!! (keys corrupt)))) | ||
(is (exception? (<!! (bget corrupt :bad (fn [_] nil))))) | ||
(is (exception? (<!! (bassoc corrupt :binbar (byte-array (range 10)))))))))) | ||
|
||
#?(:cljs (deftest compliance-test-cljs | ||
(testing "this is a test" | ||
(async done | ||
(go | ||
(let [store (<! (new-mem-store))] | ||
(is (= (<! (get store :foo)) nil)) | ||
(<! (assoc store :foo :bar)) | ||
(is (= :bar (<! (get store :foo)))) | ||
(<! (assoc-in store [:foo] :bar2)) | ||
(is (= :bar2 (<! (get store :foo)))) | ||
(is (= :default | ||
(<! (get-in store [:fuu] :default)))) | ||
(<! (update-in store [:foo] name)) | ||
(is (= "bar2" (<! (get store :foo)))) | ||
(<! (assoc-in store [:baz] {:bar 42})) | ||
(is (= (<! (get-in store [:baz :bar])) 42)) | ||
(<! (update-in store [:baz :bar] inc)) | ||
(is (= (<! (get-in store [:baz :bar])) 43)) | ||
(<! (update-in store [:baz :bar] + 2 3)) | ||
(is (= (<! (get-in store [:baz :bar])) 48)) | ||
(<! (dissoc store :foo)) | ||
(is (= (<! (get-in store [:foo])) nil)) | ||
(done))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#kaocha/v1 | ||
{:tests [{:id :unit}]} |