summaryrefslogtreecommitdiff
path: root/test/common.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-03-27 08:48:05 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-03-27 08:48:05 +0100
commit830e7c5d27d161b91402414e6ecd49f1ed818bfb (patch)
tree448864635d29b1ea66424cbb9e0816fbcf1e1907 /test/common.ml
Initial commit
Diffstat (limited to 'test/common.ml')
-rw-r--r--test/common.ml13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/common.ml b/test/common.ml
new file mode 100644
index 0000000..807289a
--- /dev/null
+++ b/test/common.ml
@@ -0,0 +1,13 @@
+(** Common fuctions shared between the tests *)
+
+let ( let* ) = Lwt.bind
+
+(** Connect to the database in memory and create a schema matching the given
+ configuration *)
+let connect : Configuration.Ast.setting -> Caqti_lwt.connection Lwt.t =
+ fun conf ->
+ let* conn = Caqti_lwt_unix.connect (Uri.of_string "sqlite3::memory:") in
+ let* db = Caqti_lwt.or_fail conn in
+ let module Db = (val db) in
+ let* () = Query.create db conf in
+ Lwt.return db