Last active
August 29, 2015 13:58
-
-
Save ekhall/9991029 to your computer and use it in GitHub Desktop.
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
(ns patient.core | |
(:require [datomic.api :as d])) | |
(def conn nil) | |
(defn add-patient [patient-name] | |
@(d/transact conn [{:db/id (d/tempid :db.part/patient) | |
:patient/name patient-name}])) | |
(defn find-all-patients [] | |
(d/q '[:find ?patient-name | |
:where [_ :patient/name ?patient-name]] | |
(d/db conn))) |
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
********************************************* | |
*************** Running tests *************** | |
failure in (core_test.clj:15) : patient.core-test | |
(expect | |
"John" | |
(with-redefs | |
[conn (create-empty-in-memory-db)] | |
(do (add-patient "John") (find-all-patients)))) | |
act-msg: exception in actual: (with-redefs [conn (create-empty-in-memory-db)] (do (add-patient "John") (find-all-patients))) | |
threw: class java.util.concurrent.ExecutionException - java.lang.IllegalArgumentException: :db.error/not-a-db-id Invalid db/id: #db/id[:db.part/patient -1000003] | |
on (promise.clj:10) | |
datomic.promise$settable_future$reify__4427$deref (promise.clj:54) | |
on (core.clj:7) | |
on (core_test.clj:18) | |
on (core_test.clj:16) | |
on (core_test.clj:15) | |
on (runner.clj:51) | |
on (runner.clj:64) | |
on (runner.clj:61) | |
on (form-init8111684156449356323.clj:1) | |
Ran 1 tests containing 1 assertions in 168 msecs | |
0 failures, 1 errors. | |
Tests completed at 07:24:02.416 |
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
[ | |
{:db/ident :patient/name | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one | |
:db/doc "A patient's name" | |
:db/id #db/id[:db.part/db] | |
:db.install/_attribute :db.part/db} | |
{:db/ident :patient/diagnostic-tests | |
:db/valueType :db.type/ref | |
:db/cardinality :db.cardinality/many | |
:db/doc "All tests for one patient" | |
:db/id #db/id[:db.part/db] | |
:db.install/_attribute :db.part/db} | |
{:db/ident :diagnostic-test/name | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one | |
:db/doc "A test's name" | |
:db/id #db/id[:db.part/db] | |
:db.install/_attribute :db.part/db} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment