Created Transacting: EDN test format (markdown)
parent
f6a76899e6
commit
dcdd46c3fc
1 changed files with 43 additions and 0 deletions
43
Transacting:-EDN-test-format.md
Normal file
43
Transacting:-EDN-test-format.md
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
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/expectedtransaction` | set | transacted datoms, w/ `added` | `#{[?tx1 :db/txInstant ?ms1 ?tx1 true]}` |
|
||||||
|
| `:test/expecteddatoms` | 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:
|
||||||
|
```edn
|
||||||
|
[?txN :db/txInstant ?msN ?txN true]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```edn
|
||||||
|
;; This is EDN, so comments are allowed.
|
||||||
|
[{:test/label "can insert two :db.cardinality/one datoms"
|
||||||
|
:test/assertions
|
||||||
|
[[:db/add 100 :db/ident :keyword/value1]
|
||||||
|
[:db/add 101 :db/ident :keyword/value2]]
|
||||||
|
:test/expectedtransaction
|
||||||
|
#{[100 :db/ident :keyword/value1 ?tx1 true]
|
||||||
|
[101 :db/ident :keyword/value2 ?tx1 true]
|
||||||
|
[?tx1 :db/txInstant ?ms1 ?tx1 true]}
|
||||||
|
:test/expecteddatoms
|
||||||
|
#{[100 :db/ident :keyword/value1]
|
||||||
|
[101 :db/ident :keyword/value2]}}]
|
||||||
|
```
|
Loading…
Reference in a new issue