summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/insert.ml31
1 files changed, 27 insertions, 4 deletions
diff --git a/test/insert.ml b/test/insert.ml
index b5da90d..c30cde4 100644
--- a/test/insert.ml
+++ b/test/insert.ml
@@ -82,7 +82,19 @@ module Make (S : Decoders.Decode.S) = struct
( "reference",
match Model.Content.find_target content key with
| None -> S.fail "Not a feature"
- | Some target_ref ->
+ | Some (Model.Typ.List list) ->
+ (* A list is referenced by the id of one of its rows *)
+ S.map
+ (fun v ->
+ Lwt.return
+ ( key,
+ Model.Typ.(
+ V
+ ( MonoReference
+ { t = Model.Typ.List list; constraints = None },
+ Some (Int64.of_int v) )) ))
+ S.int
+ | Some (Model.Typ.Content target_ref) ->
let target = Model.Reference.get target_ref in
let* properties = self#properties target in
let sequence =
@@ -92,7 +104,7 @@ module Make (S : Decoders.Decode.S) = struct
insert_and_get_result db target properties
in
let reference =
- Model.Typ.{ t = target_ref; constraints = None }
+ Model.Typ.{ t = Model.Typ.Content target_ref; constraints = None }
in
Lwt.return
( key,
@@ -103,7 +115,18 @@ module Make (S : Decoders.Decode.S) = struct
( "references",
match Model.Content.find_target content key with
| None -> S.fail "Not a feature"
- | Some target_ref ->
+ | Some (Model.Typ.List list) ->
+ S.map
+ (fun ids ->
+ Lwt.return
+ ( key,
+ Model.Typ.(
+ Seq
+ ( MultiReference
+ { t = Model.Typ.List list; constraints = None },
+ List.to_seq ids )) ))
+ (S.map (List.map ~f:Int64.of_int) (S.list S.int))
+ | Some (Model.Typ.Content target_ref) ->
let target = Model.Reference.get target_ref in
let* properties = self#values target in
let sequence =
@@ -111,7 +134,7 @@ module Make (S : Decoders.Decode.S) = struct
self#insert_and_return_references target properties
in
let reference =
- Model.Typ.{ t = target_ref; constraints = None }
+ Model.Typ.{ t = Model.Typ.Content target_ref; constraints = None }
in
Lwt.return
( key,