mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-03 22:23:10 +00:00
adding testing
This commit is contained in:
parent
567f84e460
commit
b48e45c03f
@ -12,7 +12,7 @@ import ./query
|
||||
import ./datastore
|
||||
import ./threadbackend
|
||||
|
||||
export key, query
|
||||
export key, query, ThreadBackend
|
||||
|
||||
push: {.upraises: [].}
|
||||
|
||||
@ -78,13 +78,13 @@ proc newSharedDataStore*(
|
||||
|
||||
var
|
||||
self = SharedDatastore()
|
||||
res = newThreadResult(ThreadDatastorePtr)
|
||||
# res = newThreadResult(ThreadDatastorePtr)
|
||||
|
||||
res[].signal = ThreadSignalPtr.new().valueOr:
|
||||
return failure newException(DatastoreError, "error creating signal")
|
||||
# res[].signal = ThreadSignalPtr.new().valueOr:
|
||||
# return failure newException(DatastoreError, "error creating signal")
|
||||
|
||||
res.createThreadDatastore(backend)
|
||||
await wait(res[].signal)
|
||||
res[].signal.close()
|
||||
# res.createThreadDatastore(backend)
|
||||
# await wait(res[].signal)
|
||||
# res[].signal.close()
|
||||
|
||||
success self
|
||||
|
||||
@ -29,21 +29,24 @@ type
|
||||
value*: T
|
||||
error*: CatchableErrorBuffer
|
||||
|
||||
TResult*[T] = UniquePtr[ThreadResult[T]]
|
||||
TResult*[T] = SharedPtr[ThreadResult[T]]
|
||||
|
||||
ThreadBackendKind* {.pure.} = enum
|
||||
FSBackend
|
||||
SQliteBackend
|
||||
TestBackend
|
||||
|
||||
ThreadBackend* = object
|
||||
case kind*: ThreadBackendKind
|
||||
of FSBackend:
|
||||
root: StringBuffer
|
||||
depth: int
|
||||
caseSensitive: bool
|
||||
ignoreProtected: bool
|
||||
root*: StringBuffer
|
||||
depth*: int
|
||||
caseSensitive*: bool
|
||||
ignoreProtected*: bool
|
||||
of SQliteBackend:
|
||||
discard
|
||||
of TestBackend:
|
||||
count*: int
|
||||
|
||||
ThreadDatastore = object
|
||||
tp: Taskpool
|
||||
@ -51,8 +54,8 @@ type
|
||||
|
||||
ThreadDatastorePtr* = SharedPtr[ThreadDatastore]
|
||||
|
||||
proc newThreadResult*[T](tp: typedesc[T]): UniquePtr[ThreadResult[T]] =
|
||||
newUniquePtr(ThreadResult[T])
|
||||
proc newThreadResult*[T](tp: typedesc[T]): SharedPtr[ThreadResult[T]] =
|
||||
newSharedPtr(ThreadResult[T])
|
||||
|
||||
proc startupDatastore(
|
||||
ret: TResult[ThreadDatastorePtr],
|
||||
@ -72,6 +75,11 @@ proc startupDatastore(
|
||||
ret[].state = Success
|
||||
else:
|
||||
ret[].state = Error
|
||||
ret[].value[].backendDatastore = ds.get()
|
||||
ret[].state = Success
|
||||
of TestBackend:
|
||||
ret[].value[].backendDatastore = nil
|
||||
ret[].state = Success
|
||||
else:
|
||||
discard
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user