summaryrefslogtreecommitdiff
path: root/test/update.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/update.ml')
-rw-r--r--test/update.ml50
1 files changed, 34 insertions, 16 deletions
diff --git a/test/update.ml b/test/update.ml
index 18c3821..502ad05 100644
--- a/test/update.ml
+++ b/test/update.ml
@@ -67,7 +67,10 @@ let configuration =
let speclist () =
let (lazy configuration) = configuration in
- let content = Configuration.Ast.get_content configuration (Model.Identifier.of_string "entity") in
+ let content =
+ Configuration.Ast.get_content configuration
+ (Model.Identifier.of_string "entity")
+ in
let fields = Model.Content.fields (Option.get content) in
Seq.fold_left
(fun acc feature ->
@@ -81,7 +84,10 @@ let speclist () =
Arg.String
(fun value ->
actions :=
- Text (Model.Identifier.to_string (Model.Field.name feature), value) :: !actions),
+ Text
+ ( Model.Identifier.to_string (Model.Field.name feature),
+ value )
+ :: !actions),
"<v> Set field with the value <v>" )
| Model.Typ.Integer ->
Some
@@ -89,7 +95,10 @@ let speclist () =
Arg.Int
(fun value ->
actions :=
- Integer (Model.Identifier.to_string (Model.Field.name feature), value) :: !actions),
+ Integer
+ ( Model.Identifier.to_string (Model.Field.name feature),
+ value )
+ :: !actions),
"<n> Set field with the value <n>" )
| Model.Typ.MonoReference target ->
Some
@@ -97,7 +106,10 @@ let speclist () =
Arg.Int
(fun value ->
actions :=
- Reference (target, Model.Identifier.to_string (Model.Field.name feature), value)
+ Reference
+ ( target,
+ Model.Identifier.to_string (Model.Field.name feature),
+ value )
:: !actions),
"<id> Set field with the id" )
| Model.Typ.MultiReference target ->
@@ -112,7 +124,10 @@ let speclist () =
in
actions :=
- References (target, Model.Identifier.to_string (Model.Field.name feature), ids)
+ References
+ ( target,
+ Model.Identifier.to_string (Model.Field.name feature),
+ ids )
:: !actions),
"<id,..> Set this list of values" )
in
@@ -133,7 +148,9 @@ let exec : string list -> t =
fun _ ->
let (lazy configuration) = configuration in
let content =
- Configuration.Ast.get_content configuration (Model.Identifier.of_string "entity") |> Option.get
+ Configuration.Ast.get_content configuration
+ (Model.Identifier.of_string "entity")
+ |> Option.get
in
Lwt_main.run
@@ -141,12 +158,7 @@ let exec : string list -> t =
let* db = Common.connect configuration in
let module Db = (val db) in
(* Insert a content without any value *)
- let* inserted = Query.insert db content (fun _ -> Value.none) in
- let id =
- match Value.get inserted Value.id_ref with
- | Some id -> id
- | None -> assert false
- in
+ let* id = Query.insert db content (fun _ -> Value.none) in
let group_commit : actions Seq.t Seq.t =
List.rev !actions |> List.to_seq
@@ -167,7 +179,9 @@ let exec : string list -> t =
let field =
Model.Content.fields content
|> Seq.find (fun f ->
- String.equal key (Model.Identifier.to_string (Model.Field.name f)))
+ String.equal key
+ (Model.Identifier.to_string
+ (Model.Field.name f)))
|> Option.get
in
let (Model.Field.T t) = Model.Field.type_ field in
@@ -182,13 +196,17 @@ let exec : string list -> t =
| Text (k, v) when String.equal k key ->
Some (Value.single (Model.Typ.Text, Some v))
| Integer (k, v) when String.equal k key ->
- Some (Value.single (Model.Typ.Integer, Some (Int64.of_int v)))
+ Some
+ (Value.single
+ (Model.Typ.Integer, Some (Int64.of_int v)))
| Reference (target, k, v) when String.equal k key ->
Some
(Value.single
- (Model.Typ.MonoReference target, Some (Int64.of_int v)))
+ ( Model.Typ.MonoReference target,
+ Some (Int64.of_int v) ))
| References (target, k, v) when String.equal k key ->
- Some (Value.single (Model.Typ.MultiReference target, v))
+ Some
+ (Value.single (Model.Typ.MultiReference target, v))
| _ -> None)
actions
in