2014-11-03 14:37:57 -05:00
|
|
|
! Copyright (C) 2014 Doug Coleman.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: accessors alien.c-types alien.data alien.strings
|
2014-11-04 03:19:25 -05:00
|
|
|
combinators destructors forestdb.ffi fry io.files.temp
|
|
|
|
io.pathnames kernel libc namespaces sequences tools.test ;
|
2014-11-03 14:37:57 -05:00
|
|
|
IN: forestdb.lib
|
|
|
|
|
2014-11-04 03:19:25 -05:00
|
|
|
: forestdb-test-path ( -- path )
|
|
|
|
"forestdb-test.fdb" temp-file ;
|
2014-11-03 14:37:57 -05:00
|
|
|
|
|
|
|
{ "val123" } [
|
|
|
|
forestdb-test-path [
|
2014-11-05 13:03:52 -05:00
|
|
|
"key123" "val123" fdb-set-kv
|
|
|
|
"key123" fdb-get-kv
|
2014-11-03 14:37:57 -05:00
|
|
|
] with-forestdb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ "val12345" } [
|
|
|
|
forestdb-test-path [
|
2014-11-05 13:03:52 -05:00
|
|
|
"key123" "val12345" fdb-set-kv
|
|
|
|
"key123" fdb-get-kv
|
|
|
|
] with-forestdb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
|
|
|
|
{ f } [
|
|
|
|
! Filename is only valid inside with-forestdb
|
|
|
|
forestdb-test-path [
|
|
|
|
get-current-db-info filename>> alien>native-string empty?
|
|
|
|
] with-forestdb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ 6 9 9 } [
|
|
|
|
forestdb-test-path [
|
|
|
|
"key123" "meta blah" "some body" fdb-doc-create
|
|
|
|
[ keylen>> ] [ metalen>> ] [ bodylen>> ] tri
|
|
|
|
] with-forestdb
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ 7 8 15 } [
|
|
|
|
forestdb-test-path [
|
|
|
|
"key1234" "meta blah" "some body" fdb-doc-create
|
|
|
|
dup "new meta" "some other body" fdb-doc-update
|
|
|
|
[ keylen>> ] [ metalen>> ] [ bodylen>> ] tri
|
2014-11-03 14:37:57 -05:00
|
|
|
] with-forestdb
|
|
|
|
] unit-test
|