datahike-browser-tests 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +405 -0
- package/.circleci/scripts/gen_ci.clj +194 -0
- package/.cirrus.yml +60 -0
- package/.clj-kondo/babashka/sci/config.edn +1 -0
- package/.clj-kondo/babashka/sci/sci/core.clj +9 -0
- package/.clj-kondo/config.edn +95 -0
- package/.dir-locals.el +2 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/1-bug-report.yml +68 -0
- package/.github/ISSUE_TEMPLATE/2-feature-request.yml +28 -0
- package/.github/ISSUE_TEMPLATE/config.yml +6 -0
- package/.github/pull_request_template.md +24 -0
- package/.github/workflows/native-image.yml +84 -0
- package/LICENSE +203 -0
- package/README.md +273 -0
- package/bb/deps.edn +9 -0
- package/bb/resources/github-fingerprints +3 -0
- package/bb/resources/native-image-tests/run-bb-pod-tests.clj +162 -0
- package/bb/resources/native-image-tests/run-libdatahike-tests +12 -0
- package/bb/resources/native-image-tests/run-native-image-tests +74 -0
- package/bb/resources/native-image-tests/run-python-tests +22 -0
- package/bb/resources/native-image-tests/testconfig.attr-refs.edn +6 -0
- package/bb/resources/native-image-tests/testconfig.edn +5 -0
- package/bb/resources/template/.settings/org.eclipse.jdt.apt.core.prefs +2 -0
- package/bb/resources/template/.settings/org.eclipse.jdt.core.prefs +9 -0
- package/bb/resources/template/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/bb/resources/template/pom.xml +22 -0
- package/bb/src/tools/build.clj +132 -0
- package/bb/src/tools/clj_kondo.clj +32 -0
- package/bb/src/tools/deploy.clj +26 -0
- package/bb/src/tools/examples.clj +19 -0
- package/bb/src/tools/npm.clj +100 -0
- package/bb/src/tools/python.clj +14 -0
- package/bb/src/tools/release.clj +94 -0
- package/bb/src/tools/test.clj +148 -0
- package/bb/src/tools/version.clj +47 -0
- package/bb.edn +269 -0
- package/benchmark/src/benchmark/cli.clj +195 -0
- package/benchmark/src/benchmark/compare.clj +157 -0
- package/benchmark/src/benchmark/config.clj +316 -0
- package/benchmark/src/benchmark/measure.clj +187 -0
- package/benchmark/src/benchmark/store.clj +190 -0
- package/benchmark/test/benchmark/measure_test.clj +156 -0
- package/build.clj +30 -0
- package/config.edn +49 -0
- package/deps.edn +138 -0
- package/dev/sandbox.clj +82 -0
- package/dev/sandbox.cljs +127 -0
- package/dev/sandbox_benchmarks.clj +27 -0
- package/dev/sandbox_client.clj +87 -0
- package/dev/sandbox_transact_bench.clj +109 -0
- package/dev/user.clj +79 -0
- package/doc/README.md +96 -0
- package/doc/adl/README.md +6 -0
- package/doc/adl/adr-000-adr.org +28 -0
- package/doc/adl/adr-001-attribute-references.org +15 -0
- package/doc/adl/adr-002-build-tooling.org +54 -0
- package/doc/adl/adr-003-db-meta-data.md +52 -0
- package/doc/adl/adr-004-github-flow.md +40 -0
- package/doc/adl/adr-XYZ-template.md +30 -0
- package/doc/adl/index.org +3 -0
- package/doc/assets/datahike-logo.svg +3 -0
- package/doc/assets/datahiking-invoice.org +85 -0
- package/doc/assets/hhtree2.png +0 -0
- package/doc/assets/network_topology.svg +624 -0
- package/doc/assets/perf.png +0 -0
- package/doc/assets/schema_mindmap.mm +132 -0
- package/doc/assets/schema_mindmap.svg +970 -0
- package/doc/assets/temporal_index.mm +74 -0
- package/doc/backend-development.md +78 -0
- package/doc/bb-pod.md +89 -0
- package/doc/benchmarking.md +360 -0
- package/doc/bindings/edn-conversion.md +383 -0
- package/doc/cli.md +162 -0
- package/doc/cljdoc.edn +27 -0
- package/doc/cljs-support.md +133 -0
- package/doc/config.md +406 -0
- package/doc/contributing.md +114 -0
- package/doc/datalog-vs-sql.md +210 -0
- package/doc/datomic_differences.md +109 -0
- package/doc/development/pull-api-ns.md +186 -0
- package/doc/development/pull-frame-state-diagram.jpg +0 -0
- package/doc/distributed.md +566 -0
- package/doc/entity_spec.md +92 -0
- package/doc/gc.md +273 -0
- package/doc/java-api.md +808 -0
- package/doc/javascript-api.md +421 -0
- package/doc/libdatahike.md +86 -0
- package/doc/logging_and_error_handling.md +43 -0
- package/doc/norms.md +66 -0
- package/doc/schema-migration.md +85 -0
- package/doc/schema.md +287 -0
- package/doc/storage-backends.md +363 -0
- package/doc/store-id-refactoring.md +596 -0
- package/doc/time_variance.md +325 -0
- package/doc/unstructured.md +167 -0
- package/doc/versioning.md +261 -0
- package/examples/basic/README.md +19 -0
- package/examples/basic/deps.edn +6 -0
- package/examples/basic/docker-compose.yml +13 -0
- package/examples/basic/src/examples/core.clj +60 -0
- package/examples/basic/src/examples/schema.clj +155 -0
- package/examples/basic/src/examples/store.clj +60 -0
- package/examples/basic/src/examples/time_travel.clj +185 -0
- package/examples/java/.settings/org.eclipse.core.resources.prefs +3 -0
- package/examples/java/.settings/org.eclipse.jdt.apt.core.prefs +2 -0
- package/examples/java/.settings/org.eclipse.jdt.core.prefs +9 -0
- package/examples/java/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/examples/java/README.md +162 -0
- package/examples/java/pom.xml +62 -0
- package/examples/java/src/main/java/examples/QuickStart.java +115 -0
- package/examples/java/src/main/java/examples/SchemaExample.java +148 -0
- package/examples/java/src/main/java/examples/TimeTravelExample.java +121 -0
- package/flake.lock +27 -0
- package/flake.nix +27 -0
- package/http-server/datahike/http/middleware.clj +75 -0
- package/http-server/datahike/http/server.clj +269 -0
- package/java/src/datahike/java/Database.java +274 -0
- package/java/src/datahike/java/Datahike.java +281 -0
- package/java/src/datahike/java/DatahikeGeneratedTest.java +349 -0
- package/java/src/datahike/java/DatahikeTest.java +370 -0
- package/java/src/datahike/java/EDN.java +170 -0
- package/java/src/datahike/java/IEntity.java +11 -0
- package/java/src/datahike/java/Keywords.java +161 -0
- package/java/src/datahike/java/SchemaFlexibility.java +52 -0
- package/java/src/datahike/java/Util.java +219 -0
- package/karma.conf.js +19 -0
- package/libdatahike/compile-cpp +7 -0
- package/libdatahike/src/datahike/impl/LibDatahikeBase.java +203 -0
- package/libdatahike/src/datahike/impl/libdatahike.clj +59 -0
- package/libdatahike/src/test_cpp.cpp +61 -0
- package/npm-package/PUBLISHING.md +140 -0
- package/npm-package/README.md +226 -0
- package/npm-package/package.template.json +34 -0
- package/npm-package/test-isomorphic.ts +281 -0
- package/npm-package/test.js +557 -0
- package/npm-package/typescript-test.ts +70 -0
- package/package.json +16 -0
- package/pydatahike/README.md +569 -0
- package/pydatahike/pyproject.toml +91 -0
- package/pydatahike/setup.py +42 -0
- package/pydatahike/src/datahike/__init__.py +134 -0
- package/pydatahike/src/datahike/_native.py +250 -0
- package/pydatahike/src/datahike/_version.py +2 -0
- package/pydatahike/src/datahike/database.py +722 -0
- package/pydatahike/src/datahike/edn.py +311 -0
- package/pydatahike/src/datahike/py.typed +0 -0
- package/pydatahike/tests/conftest.py +17 -0
- package/pydatahike/tests/test_basic.py +170 -0
- package/pydatahike/tests/test_database.py +51 -0
- package/pydatahike/tests/test_edn_conversion.py +299 -0
- package/pydatahike/tests/test_query.py +99 -0
- package/pydatahike/tests/test_schema.py +55 -0
- package/resources/clj-kondo.exports/io.replikativ/datahike/config.edn +5 -0
- package/resources/example_server.edn +4 -0
- package/shadow-cljs.edn +56 -0
- package/src/data_readers.clj +7 -0
- package/src/datahike/api/impl.cljc +176 -0
- package/src/datahike/api/specification.cljc +633 -0
- package/src/datahike/api/types.cljc +261 -0
- package/src/datahike/api.cljc +41 -0
- package/src/datahike/array.cljc +99 -0
- package/src/datahike/cli.clj +166 -0
- package/src/datahike/cljs.cljs +6 -0
- package/src/datahike/codegen/cli.clj +406 -0
- package/src/datahike/codegen/clj_kondo.clj +291 -0
- package/src/datahike/codegen/java.clj +403 -0
- package/src/datahike/codegen/naming.cljc +33 -0
- package/src/datahike/codegen/native.clj +559 -0
- package/src/datahike/codegen/pod.clj +488 -0
- package/src/datahike/codegen/python.clj +838 -0
- package/src/datahike/codegen/report.clj +55 -0
- package/src/datahike/codegen/typescript.clj +262 -0
- package/src/datahike/codegen/validation.clj +145 -0
- package/src/datahike/config.cljc +294 -0
- package/src/datahike/connections.cljc +16 -0
- package/src/datahike/connector.cljc +265 -0
- package/src/datahike/constants.cljc +142 -0
- package/src/datahike/core.cljc +297 -0
- package/src/datahike/datom.cljc +459 -0
- package/src/datahike/db/interface.cljc +119 -0
- package/src/datahike/db/search.cljc +305 -0
- package/src/datahike/db/transaction.cljc +937 -0
- package/src/datahike/db/utils.cljc +338 -0
- package/src/datahike/db.cljc +956 -0
- package/src/datahike/experimental/unstructured.cljc +126 -0
- package/src/datahike/experimental/versioning.cljc +172 -0
- package/src/datahike/externs.js +31 -0
- package/src/datahike/gc.cljc +69 -0
- package/src/datahike/http/client.clj +188 -0
- package/src/datahike/http/writer.clj +79 -0
- package/src/datahike/impl/entity.cljc +218 -0
- package/src/datahike/index/interface.cljc +93 -0
- package/src/datahike/index/persistent_set.cljc +469 -0
- package/src/datahike/index/utils.cljc +44 -0
- package/src/datahike/index.cljc +32 -0
- package/src/datahike/js/api.cljs +172 -0
- package/src/datahike/js/api_macros.clj +22 -0
- package/src/datahike/js.cljs +163 -0
- package/src/datahike/json.cljc +209 -0
- package/src/datahike/lru.cljc +146 -0
- package/src/datahike/migrate.clj +39 -0
- package/src/datahike/norm/norm.clj +245 -0
- package/src/datahike/online_gc.cljc +252 -0
- package/src/datahike/pod.clj +155 -0
- package/src/datahike/pull_api.cljc +325 -0
- package/src/datahike/query.cljc +1945 -0
- package/src/datahike/query_stats.cljc +88 -0
- package/src/datahike/readers.cljc +62 -0
- package/src/datahike/remote.cljc +218 -0
- package/src/datahike/schema.cljc +228 -0
- package/src/datahike/schema_cache.cljc +42 -0
- package/src/datahike/spec.cljc +101 -0
- package/src/datahike/store.cljc +80 -0
- package/src/datahike/tools.cljc +308 -0
- package/src/datahike/transit.cljc +80 -0
- package/src/datahike/writer.cljc +239 -0
- package/src/datahike/writing.cljc +362 -0
- package/src/deps.cljs +1 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree/insert.cljc +76 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree/upsert.cljc +128 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree.cljc +213 -0
- package/test/datahike/backward_compatibility_test/src/backward_test.clj +37 -0
- package/test/datahike/integration_test/config_record_file_test.clj +14 -0
- package/test/datahike/integration_test/config_record_test.clj +14 -0
- package/test/datahike/integration_test/depr_config_uri_test.clj +15 -0
- package/test/datahike/integration_test/return_map_test.clj +62 -0
- package/test/datahike/integration_test.cljc +67 -0
- package/test/datahike/norm/norm_test.clj +124 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/004-tx-data-and-tx-fn-test.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/01-transact-basic-characters.edn +2 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/02 add occupation.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/checksums.edn +12 -0
- package/test/datahike/norm/resources/simple-test/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/simple-test/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/simple-test/checksums.edn +4 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/checksums.edn +6 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/second/004-tx-data-and-tx-fn-test.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/second/checksums.edn +2 -0
- package/test/datahike/norm/resources/tx-fn-test/first/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/tx-fn-test/first/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/tx-fn-test/first/checksums.edn +4 -0
- package/test/datahike/norm/resources/tx-fn-test/second/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/tx-fn-test/second/checksums.edn +2 -0
- package/test/datahike/test/api_test.cljc +895 -0
- package/test/datahike/test/array_test.cljc +40 -0
- package/test/datahike/test/attribute_refs/datoms_test.cljc +140 -0
- package/test/datahike/test/attribute_refs/db_test.cljc +42 -0
- package/test/datahike/test/attribute_refs/differences_test.cljc +515 -0
- package/test/datahike/test/attribute_refs/entity_test.cljc +89 -0
- package/test/datahike/test/attribute_refs/pull_api_test.cljc +320 -0
- package/test/datahike/test/attribute_refs/query_find_specs_test.cljc +59 -0
- package/test/datahike/test/attribute_refs/query_fns_test.cljc +130 -0
- package/test/datahike/test/attribute_refs/query_interop_test.cljc +47 -0
- package/test/datahike/test/attribute_refs/query_not_test.cljc +193 -0
- package/test/datahike/test/attribute_refs/query_or_test.cljc +137 -0
- package/test/datahike/test/attribute_refs/query_pull_test.cljc +156 -0
- package/test/datahike/test/attribute_refs/query_rules_test.cljc +176 -0
- package/test/datahike/test/attribute_refs/query_test.cljc +241 -0
- package/test/datahike/test/attribute_refs/temporal_search.cljc +22 -0
- package/test/datahike/test/attribute_refs/transact_test.cljc +220 -0
- package/test/datahike/test/attribute_refs/utils.cljc +128 -0
- package/test/datahike/test/cache_test.cljc +38 -0
- package/test/datahike/test/components_test.cljc +92 -0
- package/test/datahike/test/config_test.cljc +158 -0
- package/test/datahike/test/core_test.cljc +105 -0
- package/test/datahike/test/datom_test.cljc +44 -0
- package/test/datahike/test/db_test.cljc +54 -0
- package/test/datahike/test/entity_spec_test.cljc +159 -0
- package/test/datahike/test/entity_test.cljc +103 -0
- package/test/datahike/test/explode_test.cljc +143 -0
- package/test/datahike/test/filter_test.cljc +75 -0
- package/test/datahike/test/gc_test.cljc +159 -0
- package/test/datahike/test/http/server_test.clj +192 -0
- package/test/datahike/test/http/writer_test.clj +86 -0
- package/test/datahike/test/ident_test.cljc +32 -0
- package/test/datahike/test/index_test.cljc +345 -0
- package/test/datahike/test/insert.cljc +125 -0
- package/test/datahike/test/java_bindings_test.clj +6 -0
- package/test/datahike/test/listen_test.cljc +41 -0
- package/test/datahike/test/lookup_refs_test.cljc +266 -0
- package/test/datahike/test/lru_test.cljc +27 -0
- package/test/datahike/test/migrate_test.clj +297 -0
- package/test/datahike/test/model/core.cljc +376 -0
- package/test/datahike/test/model/invariant.cljc +142 -0
- package/test/datahike/test/model/rng.cljc +82 -0
- package/test/datahike/test/model_test.clj +217 -0
- package/test/datahike/test/nodejs_test.cljs +262 -0
- package/test/datahike/test/online_gc_test.cljc +475 -0
- package/test/datahike/test/pod_test.clj +369 -0
- package/test/datahike/test/pull_api_test.cljc +474 -0
- package/test/datahike/test/purge_test.cljc +144 -0
- package/test/datahike/test/query_aggregates_test.cljc +101 -0
- package/test/datahike/test/query_find_specs_test.cljc +52 -0
- package/test/datahike/test/query_fns_test.cljc +523 -0
- package/test/datahike/test/query_interop_test.cljc +47 -0
- package/test/datahike/test/query_not_test.cljc +189 -0
- package/test/datahike/test/query_or_test.cljc +158 -0
- package/test/datahike/test/query_pull_test.cljc +147 -0
- package/test/datahike/test/query_rules_test.cljc +248 -0
- package/test/datahike/test/query_stats_test.cljc +218 -0
- package/test/datahike/test/query_test.cljc +984 -0
- package/test/datahike/test/schema_test.cljc +424 -0
- package/test/datahike/test/specification_test.cljc +30 -0
- package/test/datahike/test/store_test.cljc +78 -0
- package/test/datahike/test/stress_test.cljc +57 -0
- package/test/datahike/test/time_variance_test.cljc +518 -0
- package/test/datahike/test/tools_test.clj +134 -0
- package/test/datahike/test/transact_test.cljc +518 -0
- package/test/datahike/test/tuples_test.cljc +564 -0
- package/test/datahike/test/unstructured_test.cljc +291 -0
- package/test/datahike/test/upsert_impl_test.cljc +205 -0
- package/test/datahike/test/upsert_test.cljc +363 -0
- package/test/datahike/test/utils.cljc +110 -0
- package/test/datahike/test/validation_test.cljc +48 -0
- package/test/datahike/test/versioning_test.cljc +56 -0
- package/test/datahike/test.cljc +66 -0
- package/tests.edn +24 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
(ns datahike.test.pod-test
|
|
2
|
+
"Integration tests for datahike.pod functions.
|
|
3
|
+
|
|
4
|
+
These tests verify the pod API works correctly without going through
|
|
5
|
+
the native image + babashka pod protocol. This allows faster CI feedback."
|
|
6
|
+
(:require [clojure.test :refer [deftest testing is use-fixtures]]
|
|
7
|
+
[datahike.pod :as pod]
|
|
8
|
+
[datahike.api :as d])
|
|
9
|
+
(:import [java.util Date]))
|
|
10
|
+
|
|
11
|
+
(def test-config
|
|
12
|
+
{:keep-history? true
|
|
13
|
+
:search-cache-size 10000
|
|
14
|
+
:index :datahike.index/persistent-set
|
|
15
|
+
:store {:id #uuid "550e8400-e29b-41d4-a716-446655440001"
|
|
16
|
+
:backend :memory
|
|
17
|
+
:scope "pod-test"}
|
|
18
|
+
:store-cache-size 1000
|
|
19
|
+
:attribute-refs? false
|
|
20
|
+
:writer {:backend :self}
|
|
21
|
+
:crypto-hash? false
|
|
22
|
+
:schema-flexibility :read
|
|
23
|
+
:branch :db})
|
|
24
|
+
|
|
25
|
+
(defn reset-db-fixture [f]
|
|
26
|
+
;; Clean up before test
|
|
27
|
+
(pod/delete-database test-config)
|
|
28
|
+
(reset! pod/conns {})
|
|
29
|
+
(reset! pod/dbs {})
|
|
30
|
+
(f)
|
|
31
|
+
;; Clean up after test
|
|
32
|
+
(reset! pod/conns {})
|
|
33
|
+
(reset! pod/dbs {}))
|
|
34
|
+
|
|
35
|
+
(use-fixtures :each reset-db-fixture)
|
|
36
|
+
|
|
37
|
+
;; =============================================================================
|
|
38
|
+
;; Database Lifecycle Tests
|
|
39
|
+
;; =============================================================================
|
|
40
|
+
|
|
41
|
+
(deftest database-lifecycle-test
|
|
42
|
+
(testing "create-database returns config"
|
|
43
|
+
(let [result (pod/create-database test-config)]
|
|
44
|
+
(is (map? result))
|
|
45
|
+
(is (= :memory (get-in result [:store :backend])))))
|
|
46
|
+
|
|
47
|
+
(testing "database-exists? returns true after create"
|
|
48
|
+
(is (= true (pod/database-exists? test-config))))
|
|
49
|
+
|
|
50
|
+
(testing "delete-database returns nil"
|
|
51
|
+
(is (nil? (pod/delete-database test-config))))
|
|
52
|
+
|
|
53
|
+
(testing "database-exists? returns false after delete"
|
|
54
|
+
(is (= false (pod/database-exists? test-config)))))
|
|
55
|
+
|
|
56
|
+
;; =============================================================================
|
|
57
|
+
;; Connection Tests
|
|
58
|
+
;; =============================================================================
|
|
59
|
+
|
|
60
|
+
(deftest connection-test
|
|
61
|
+
(pod/create-database test-config)
|
|
62
|
+
|
|
63
|
+
(testing "connect returns conn-id string"
|
|
64
|
+
(let [conn-id (pod/connect test-config)]
|
|
65
|
+
(is (string? conn-id))
|
|
66
|
+
(is (clojure.string/starts-with? conn-id "conn:"))))
|
|
67
|
+
|
|
68
|
+
(testing "connect with same config returns same conn-id"
|
|
69
|
+
(let [conn-id1 (pod/connect test-config)
|
|
70
|
+
conn-id2 (pod/connect test-config)]
|
|
71
|
+
(is (= conn-id1 conn-id2))))
|
|
72
|
+
|
|
73
|
+
(testing "release removes connection"
|
|
74
|
+
(let [conn-id (pod/connect test-config)]
|
|
75
|
+
(is (contains? @pod/conns conn-id))
|
|
76
|
+
(pod/release conn-id)
|
|
77
|
+
(is (not (contains? @pod/conns conn-id))))))
|
|
78
|
+
|
|
79
|
+
;; =============================================================================
|
|
80
|
+
;; Database Access Tests
|
|
81
|
+
;; =============================================================================
|
|
82
|
+
|
|
83
|
+
(deftest db-access-test
|
|
84
|
+
(pod/create-database test-config)
|
|
85
|
+
(let [conn-id (pod/connect test-config)]
|
|
86
|
+
|
|
87
|
+
(testing "db returns db-id string (UUID format)"
|
|
88
|
+
(let [db-id (pod/db conn-id)]
|
|
89
|
+
(is (string? db-id))
|
|
90
|
+
;; Should be a UUID string (commit-id)
|
|
91
|
+
(is (re-matches #"[0-9a-f-]+" db-id))))
|
|
92
|
+
|
|
93
|
+
(testing "db caches database with conn-id reference"
|
|
94
|
+
(let [db-id (pod/db conn-id)
|
|
95
|
+
entry (get @pod/dbs db-id)]
|
|
96
|
+
(is (some? entry))
|
|
97
|
+
(is (= conn-id (:conn-id entry)))
|
|
98
|
+
(is (some? (:db entry)))))
|
|
99
|
+
|
|
100
|
+
(testing "release-db removes from cache"
|
|
101
|
+
(let [db-id (pod/db conn-id)]
|
|
102
|
+
(is (contains? @pod/dbs db-id))
|
|
103
|
+
(is (= {} (pod/release-db db-id)))
|
|
104
|
+
(is (not (contains? @pod/dbs db-id)))))
|
|
105
|
+
|
|
106
|
+
(pod/release conn-id)))
|
|
107
|
+
|
|
108
|
+
;; =============================================================================
|
|
109
|
+
;; Transaction Tests
|
|
110
|
+
;; =============================================================================
|
|
111
|
+
|
|
112
|
+
(deftest transact-test
|
|
113
|
+
(pod/create-database test-config)
|
|
114
|
+
(let [conn-id (pod/connect test-config)]
|
|
115
|
+
|
|
116
|
+
(testing "transact returns summarized tx-report"
|
|
117
|
+
(let [result (pod/transact conn-id [{:name "Alice" :age 30}])]
|
|
118
|
+
(is (map? result))
|
|
119
|
+
(is (contains? result :tempids))
|
|
120
|
+
(is (contains? result :db-before))
|
|
121
|
+
(is (contains? result :db-after))
|
|
122
|
+
(is (contains? result :tx-meta))
|
|
123
|
+
(is (contains? result :tx-data))
|
|
124
|
+
;; db-before/after should be summarized (only :max-tx :max-eid)
|
|
125
|
+
(is (= #{:max-tx :max-eid} (set (keys (:db-before result)))))
|
|
126
|
+
(is (= #{:max-tx :max-eid} (set (keys (:db-after result)))))))
|
|
127
|
+
|
|
128
|
+
(testing "transact with map syntax"
|
|
129
|
+
(let [result (pod/transact conn-id {:tx-data [{:name "Bob" :age 25}]})]
|
|
130
|
+
(is (map? result))))
|
|
131
|
+
|
|
132
|
+
(pod/release conn-id)))
|
|
133
|
+
|
|
134
|
+
;; =============================================================================
|
|
135
|
+
;; Query Tests
|
|
136
|
+
;; =============================================================================
|
|
137
|
+
|
|
138
|
+
(deftest query-test
|
|
139
|
+
(pod/create-database test-config)
|
|
140
|
+
(let [conn-id (pod/connect test-config)]
|
|
141
|
+
(pod/transact conn-id [{:name "Alice" :age 20}
|
|
142
|
+
{:name "Bob" :age 30}
|
|
143
|
+
{:name "Charlie" :age 40}])
|
|
144
|
+
|
|
145
|
+
(testing "q with map syntax"
|
|
146
|
+
(let [db-id (pod/db conn-id)
|
|
147
|
+
result (pod/q {:query '{:find [?e ?n]
|
|
148
|
+
:where [[?e :name ?n]]}
|
|
149
|
+
:args [db-id]})]
|
|
150
|
+
(is (set? result))
|
|
151
|
+
(is (= 3 (count result)))
|
|
152
|
+
(pod/release-db db-id)))
|
|
153
|
+
|
|
154
|
+
(testing "q with vector syntax"
|
|
155
|
+
(let [db-id (pod/db conn-id)
|
|
156
|
+
result (pod/q '[:find ?e ?n :where [?e :name ?n]] db-id)]
|
|
157
|
+
(is (set? result))
|
|
158
|
+
(is (= 3 (count result)))
|
|
159
|
+
(pod/release-db db-id)))
|
|
160
|
+
|
|
161
|
+
(pod/release conn-id)))
|
|
162
|
+
|
|
163
|
+
;; =============================================================================
|
|
164
|
+
;; Pull Tests
|
|
165
|
+
;; =============================================================================
|
|
166
|
+
|
|
167
|
+
(deftest pull-test
|
|
168
|
+
(pod/create-database test-config)
|
|
169
|
+
(let [conn-id (pod/connect test-config)]
|
|
170
|
+
(pod/transact conn-id [{:name "Alice" :age 20}])
|
|
171
|
+
|
|
172
|
+
(testing "pull with selector and eid"
|
|
173
|
+
(let [db-id (pod/db conn-id)
|
|
174
|
+
result (pod/pull db-id '[*] 1)]
|
|
175
|
+
(is (map? result))
|
|
176
|
+
(is (= "Alice" (:name result)))
|
|
177
|
+
(is (= 20 (:age result)))
|
|
178
|
+
(pod/release-db db-id)))
|
|
179
|
+
|
|
180
|
+
(testing "pull-many"
|
|
181
|
+
(pod/transact conn-id [{:name "Bob" :age 30}])
|
|
182
|
+
(let [db-id (pod/db conn-id)
|
|
183
|
+
result (pod/pull-many db-id '[*] [1 2])]
|
|
184
|
+
(is (sequential? result))
|
|
185
|
+
(is (= 2 (count result)))
|
|
186
|
+
(pod/release-db db-id)))
|
|
187
|
+
|
|
188
|
+
(pod/release conn-id)))
|
|
189
|
+
|
|
190
|
+
;; =============================================================================
|
|
191
|
+
;; Entity Tests
|
|
192
|
+
;; =============================================================================
|
|
193
|
+
|
|
194
|
+
(deftest entity-test
|
|
195
|
+
(pod/create-database test-config)
|
|
196
|
+
(let [conn-id (pod/connect test-config)]
|
|
197
|
+
(pod/transact conn-id [{:name "Alice" :age 20}])
|
|
198
|
+
|
|
199
|
+
(testing "entity returns plain map"
|
|
200
|
+
(let [db-id (pod/db conn-id)
|
|
201
|
+
result (pod/entity db-id 1)]
|
|
202
|
+
(is (map? result))
|
|
203
|
+
(is (= "Alice" (:name result)))
|
|
204
|
+
(is (= 20 (:age result)))
|
|
205
|
+
;; Should NOT have :db/id (entity transform strips it)
|
|
206
|
+
(is (not (contains? result :db/id)))
|
|
207
|
+
(pod/release-db db-id)))
|
|
208
|
+
|
|
209
|
+
(pod/release conn-id)))
|
|
210
|
+
|
|
211
|
+
;; =============================================================================
|
|
212
|
+
;; Temporal Tests
|
|
213
|
+
;; =============================================================================
|
|
214
|
+
|
|
215
|
+
(deftest temporal-test
|
|
216
|
+
(pod/create-database test-config)
|
|
217
|
+
(let [conn-id (pod/connect test-config)]
|
|
218
|
+
(pod/transact conn-id [{:name "Alice" :age 20}])
|
|
219
|
+
(let [timestamp (Date.)]
|
|
220
|
+
(Thread/sleep 10)
|
|
221
|
+
(pod/transact conn-id [{:db/id 1 :age 21}])
|
|
222
|
+
|
|
223
|
+
(testing "as-of returns db-id"
|
|
224
|
+
(let [db-id (pod/db conn-id)
|
|
225
|
+
asof-id (pod/as-of db-id timestamp)]
|
|
226
|
+
(is (string? asof-id))
|
|
227
|
+
;; Query as-of should see old age
|
|
228
|
+
(let [result (pod/q '[:find ?a . :where [1 :age ?a]] asof-id)]
|
|
229
|
+
(is (= 20 result)))
|
|
230
|
+
(pod/release-db db-id)
|
|
231
|
+
(pod/release-db asof-id)))
|
|
232
|
+
|
|
233
|
+
(testing "since returns db-id"
|
|
234
|
+
(let [db-id (pod/db conn-id)
|
|
235
|
+
since-id (pod/since db-id timestamp)]
|
|
236
|
+
(is (string? since-id))
|
|
237
|
+
(pod/release-db db-id)
|
|
238
|
+
(pod/release-db since-id)))
|
|
239
|
+
|
|
240
|
+
(testing "history returns db-id"
|
|
241
|
+
(let [db-id (pod/db conn-id)
|
|
242
|
+
hist-id (pod/history db-id)]
|
|
243
|
+
(is (string? hist-id))
|
|
244
|
+
;; History should include both old and new age
|
|
245
|
+
(let [result (pod/q '[:find ?a :where [1 :age ?a]] hist-id)]
|
|
246
|
+
(is (= #{[20] [21]} result)))
|
|
247
|
+
(pod/release-db db-id)
|
|
248
|
+
(pod/release-db hist-id))))
|
|
249
|
+
|
|
250
|
+
(pod/release conn-id)))
|
|
251
|
+
|
|
252
|
+
;; =============================================================================
|
|
253
|
+
;; db-with Tests
|
|
254
|
+
;; =============================================================================
|
|
255
|
+
|
|
256
|
+
(deftest db-with-test
|
|
257
|
+
(pod/create-database test-config)
|
|
258
|
+
(let [conn-id (pod/connect test-config)]
|
|
259
|
+
(pod/transact conn-id [{:name "Alice" :age 20}])
|
|
260
|
+
|
|
261
|
+
(testing "db-with returns speculative db-id"
|
|
262
|
+
(let [db-id (pod/db conn-id)
|
|
263
|
+
with-id (pod/db-with db-id [{:name "Bob" :age 30}])]
|
|
264
|
+
(is (string? with-id))
|
|
265
|
+
;; Speculative db should have Bob
|
|
266
|
+
(let [result (pod/q '[:find ?n :where [_ :name ?n]] with-id)]
|
|
267
|
+
(is (contains? result ["Bob"])))
|
|
268
|
+
;; Original db should NOT have Bob
|
|
269
|
+
(let [result (pod/q '[:find ?n :where [_ :name ?n]] db-id)]
|
|
270
|
+
(is (not (contains? result ["Bob"]))))
|
|
271
|
+
(pod/release-db db-id)
|
|
272
|
+
(pod/release-db with-id)))
|
|
273
|
+
|
|
274
|
+
(pod/release conn-id)))
|
|
275
|
+
|
|
276
|
+
;; =============================================================================
|
|
277
|
+
;; Index Operations Tests
|
|
278
|
+
;; =============================================================================
|
|
279
|
+
|
|
280
|
+
(deftest datoms-test
|
|
281
|
+
(pod/create-database test-config)
|
|
282
|
+
(let [conn-id (pod/connect test-config)]
|
|
283
|
+
(pod/transact conn-id [{:name "Alice" :age 20}])
|
|
284
|
+
|
|
285
|
+
(testing "datoms with map syntax"
|
|
286
|
+
(let [db-id (pod/db conn-id)
|
|
287
|
+
result (pod/datoms db-id {:index :eavt :components [1]})]
|
|
288
|
+
(is (sequential? result))
|
|
289
|
+
(is (every? sequential? result))
|
|
290
|
+
(pod/release-db db-id)))
|
|
291
|
+
|
|
292
|
+
(testing "datoms with variadic positional syntax"
|
|
293
|
+
(let [db-id (pod/db conn-id)
|
|
294
|
+
result (pod/datoms db-id :eavt 1 :age)]
|
|
295
|
+
(is (sequential? result))
|
|
296
|
+
(pod/release-db db-id)))
|
|
297
|
+
|
|
298
|
+
(pod/release conn-id)))
|
|
299
|
+
|
|
300
|
+
;; =============================================================================
|
|
301
|
+
;; Schema Tests
|
|
302
|
+
;; =============================================================================
|
|
303
|
+
|
|
304
|
+
(deftest schema-test
|
|
305
|
+
(pod/create-database test-config)
|
|
306
|
+
(let [conn-id (pod/connect test-config)]
|
|
307
|
+
;; Add schema
|
|
308
|
+
(pod/transact conn-id [{:db/ident :name
|
|
309
|
+
:db/valueType :db.type/string
|
|
310
|
+
:db/cardinality :db.cardinality/one}])
|
|
311
|
+
|
|
312
|
+
(testing "schema returns schema map"
|
|
313
|
+
(let [db-id (pod/db conn-id)
|
|
314
|
+
result (pod/schema db-id)]
|
|
315
|
+
(is (map? result))
|
|
316
|
+
(is (contains? result :name))
|
|
317
|
+
(pod/release-db db-id)))
|
|
318
|
+
|
|
319
|
+
(testing "reverse-schema returns reverse schema"
|
|
320
|
+
(let [db-id (pod/db conn-id)
|
|
321
|
+
result (pod/reverse-schema db-id)]
|
|
322
|
+
(is (map? result))
|
|
323
|
+
(pod/release-db db-id)))
|
|
324
|
+
|
|
325
|
+
(pod/release conn-id)))
|
|
326
|
+
|
|
327
|
+
;; =============================================================================
|
|
328
|
+
;; Metrics Tests
|
|
329
|
+
;; =============================================================================
|
|
330
|
+
|
|
331
|
+
(deftest metrics-test
|
|
332
|
+
(pod/create-database test-config)
|
|
333
|
+
(let [conn-id (pod/connect test-config)]
|
|
334
|
+
(pod/transact conn-id [{:name "Alice" :age 20}])
|
|
335
|
+
|
|
336
|
+
(testing "metrics returns metrics map"
|
|
337
|
+
(let [db-id (pod/db conn-id)
|
|
338
|
+
result (pod/metrics db-id)]
|
|
339
|
+
(is (map? result))
|
|
340
|
+
(is (contains? result :count))
|
|
341
|
+
(is (contains? result :per-attr-counts))
|
|
342
|
+
(pod/release-db db-id)))
|
|
343
|
+
|
|
344
|
+
(pod/release conn-id)))
|
|
345
|
+
|
|
346
|
+
;; =============================================================================
|
|
347
|
+
;; Connection Tracking Tests
|
|
348
|
+
;; =============================================================================
|
|
349
|
+
|
|
350
|
+
(deftest connection-tracking-test
|
|
351
|
+
(pod/create-database test-config)
|
|
352
|
+
(let [conn-id (pod/connect test-config)]
|
|
353
|
+
(pod/transact conn-id [{:name "Alice"}])
|
|
354
|
+
|
|
355
|
+
(testing "db entries track parent conn-id"
|
|
356
|
+
(let [db-id (pod/db conn-id)
|
|
357
|
+
entry (get @pod/dbs db-id)]
|
|
358
|
+
(is (= conn-id (:conn-id entry)))
|
|
359
|
+
(pod/release-db db-id)))
|
|
360
|
+
|
|
361
|
+
(testing "temporal dbs inherit conn-id"
|
|
362
|
+
(let [db-id (pod/db conn-id)
|
|
363
|
+
hist-id (pod/history db-id)
|
|
364
|
+
hist-entry (get @pod/dbs hist-id)]
|
|
365
|
+
(is (= conn-id (:conn-id hist-entry)))
|
|
366
|
+
(pod/release-db db-id)
|
|
367
|
+
(pod/release-db hist-id)))
|
|
368
|
+
|
|
369
|
+
(pod/release conn-id)))
|