1 ! Copyright (C) 2014 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.strings arrays forestdb.lib forestdb.utils kernel
4 make multiline sequences tools.test ;
11 "key123" "val123" fdb-set-kv
14 ] with-forestdb-test-manual
20 "key123" "val12345" fdb-set-kv
23 ] with-forestdb-test-manual
35 fdb_doc>doc [ key>> ] [ body>> ] bi 2array
37 ] with-forestdb-test-manual
47 "key1" "no meta" "going away" [
49 fdb_doc>doc [ key>> ] [ meta>> ] [ body>> ] tri 3array
51 ] with-forestdb-test-manual
62 fdb-get-byseq fdb_doc>doc
63 [ key>> ] [ meta>> ] [ body>> ] tri 3array
65 ] with-forestdb-test-manual
75 fdb-get-byseq fdb_doc>doc
76 [ key>> ] [ meta>> ] [ body>> ] tri 3array
78 ] with-forestdb-test-manual
81 ! Filename is only valid inside with-forestdb
84 fdb-get-info filename>> alien>native-string empty?
85 ] with-forestdb-test-manual
91 "key123" "meta blah" "some body" [
92 [ keylen>> ] [ metalen>> ] [ bodylen>> ] tri
94 ] with-forestdb-test-manual
99 "key1234" "meta blah" "some body" [
100 [ "new meta" "some other body" fdb-doc-update ]
101 [ [ keylen>> ] [ metalen>> ] [ bodylen>> ] tri ] bi
103 ] with-forestdb-test-manual
110 fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
111 ] with-forestdb-test-manual
119 fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
120 ] with-forestdb-test-manual
127 fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
128 ] with-forestdb-test-manual
139 fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
140 ] with-forestdb-snapshot
141 ] with-forestdb-test-manual
147 ! Snapshots can only occur on commits. If you commit five keys at once,
148 ! and then try to open a snapshot on the second key, it should fail.
150 ! XXX: Buggy, fails in _fdb_open with FDB_RESULT_NO_DB_INSTANCE
157 fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
158 ] with-forestdb-snapshot
159 ] with-forestdb-tester
161 T{ fdb-error { error FDB_RESULT_NO_DB_INSTANCE } } =
164 ! Test that we take two snapshots and their seqnums/doc counts are right.
165 ! XXX: Buggy, want to see the first snapshot's document count at 5 too
179 fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi 2array
180 ] with-forestdb-snapshot
183 fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi 2array
184 ] with-forestdb-snapshot
185 ] with-forestdb-tester
189 ! Same test as above, but with buggy behavior for now so it passes
203 fdb-get-kvs-info last_seqnum>>
204 ] with-forestdb-snapshot
207 fdb-get-kvs-info last_seqnum>>
208 ] with-forestdb-snapshot
209 ] with-forestdb-tester
216 ! Make sure the doc_count is correct after a rollback
230 fdb-get-kvs-info last_seqnum>>
231 ] with-forestdb-snapshot
236 fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi 2array
237 ] with-forestdb-snapshot
238 ] with-forestdb-tester
254 fdb_doc>doc [ seqnum>> ] [ key>> ] [ body>> ] tri 3array ,
255 ] with-fdb-normal-iterator
257 ] with-forestdb-test-manual
275 fdb_doc>doc [ seqnum>> ] [ key>> ] [ body>> ] tri 3array ,
276 ] with-fdb-normal-iterator
278 ] with-forestdb-test-manual
281 ! Test that keys at extremes get returned
292 fdb_doc>doc [ seqnum>> ] [ key>> ] [ body>> ] tri 3array ,
293 ] with-fdb-normal-iterator
295 ] with-forestdb-test-manual
308 fdb_doc>doc [ seqnum>> ] [ key>> ] [ body>> ] tri 3array ,
309 ] with-fdb-normal-iterator
311 ] with-forestdb-test-manual
326 ] with-forestdb-test-manual
329 ! XXX: Behavior changed here
330 ! No longer makes new docs that are deleted
331 ! Deleting 5 keys gives you 5 new seqnums that are those docs, but deleted
333 ! V{ { 6 t } { 7 t } { 8 t } { 9 t } { 10 t } }
341 ! ] with-fdb-byseq-map
342 ! [ [ seqnum>> ] [ deleted?>> ] bi 2array ] map
343 ! ] with-forestdb-test-manual
357 [ [ seqnum>> ] [ deleted?>> ] bi 2array ] map
358 ] with-forestdb-test-manual
377 [ [ key>> ] [ keylen>> ] bi alien/length>string ] bi 2array ,
378 ] with-fdb-byseq-each
380 ] with-forestdb-test-manual