You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jordan Santell edited this page Feb 11, 2017
·
2 revisions
The Rust and Clojure{Script} implementations of Mentat share part of their test suites. Tests in this suite are text files in EDN format that label what is being tested, represent assertions to apply to a bootstrapped store, and capture expectations of what parts of the store should look like after the assertions are transacted.
Format
The top-level element should be a vector of transactions. Each transaction should be a map with the following required keys:
key
type
description
example
:test/label
string
a brief description of what the transaction is testing
":db/add ignores existing datoms"
:test/assertions
vector
valid Mentat transaction data
[[:db/add E A V]]
and at least one of the following optional keys:
key
type
description
example
:test/expected-transaction
set
transacted datoms, w/ added
#{[?tx1 :db/txInstant ?ms1 ?tx1 true]}
:test/expected-datoms
set
all datoms after bootstrap, w/o :db/txInstant datoms
#{[E A V ?tx1]}
Special values
Transaction identifiers are replaced with ?txN, where N counts the transaction number after the initial bootstrap transaction. Therefore, the first tested transaction is ?tx1, the next ?tx2, and so on. Transaction timestamps are replaced with ?mxN, where N is as above.
Therefore every expected transaction should include a datom like:
[?txN :db/txInstant ?msN ?txN true]
Example
;; This is EDN, so comments are allowed.
[{:test/label"can insert two :db.cardinality/one datoms":test/assertions
[[:db/add100:db/ident:keyword/value1]
[:db/add101:db/ident:keyword/value2]]
:test/expected-transaction
#{[100:db/ident:keyword/value1 ?tx1 true]
[101:db/ident:keyword/value2 ?tx1 true]
[?tx1 :db/txInstant ?ms1 ?tx1 true]}
:test/expected-datoms
#{[100:db/ident:keyword/value1]
[101:db/ident:keyword/value2]}}]