diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-08-01 01:44:43 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-01 01:44:43 +0000 |
| commit | 117fe888ef9325dbc6965e36c38e40c92d7bc1ee (patch) | |
| tree | 366688654cf0a38b302c22b5151a11f6734dc6d8 /test/Helpers.ml | |
| parent | d57288a6143146a99fd1792c543dbade2758ad01 (diff) | |
| parent | b7a09b8c8913b26eb22b98aa77a324a1c23736e2 (diff) | |
| download | RNT-117fe888ef9325dbc6965e36c38e40c92d7bc1ee.tar.gz RNT-117fe888ef9325dbc6965e36c38e40c92d7bc1ee.zip | |
Merge pull request #48 from dont-rely-on-nulls/merkle-tree-tests
Basic tests for the B-tree, and a slightly friendlier storage interface
Diffstat (limited to 'test/Helpers.ml')
| -rw-r--r-- | test/Helpers.ml | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Helpers.ml b/test/Helpers.ml index bf34b82..784170c 100644 --- a/test/Helpers.ml +++ b/test/Helpers.ml @@ -17,3 +17,28 @@ let condition_as_failure = function let pp_value ppf v = Format.pp_print_string ppf (Concepts.Value.to_string v) let value = Alcotest.testable pp_value Concepts.Value.equal + +module Storage = struct + module type CONFIGURATOR = sig + val configure : string -> Rnt.Concepts.Configuration.term + end + + module LMDB_Configurator : CONFIGURATOR = struct + let configure base = + let open Sexplib.Sexp in + List [Atom "lmdb"; List [Atom "path"; Atom base]; List [Atom "mode"; Atom "420"]] + |> Rnt.Concepts.Configuration.term_of_sexp + end + + module Make (S : Abstract.Storage.STORAGE) (C : CONFIGURATOR) = struct + let with_connection f dir () = + with_temporary_directory dir begin fun dir -> + begin + let open Utilities.Result in + let* conn = S.connect (C.configure dir) in + Ok (f conn) + end + |> condition_as_failure + end + end +end |
