Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
timohuber committed Sep 23, 2024
1 parent 8cd7321 commit 0d8daf6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
63 changes: 63 additions & 0 deletions pool/test/changelog_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,66 @@ let create_nested () =
changelog
expected
;;

let update_filter () =
let open Filter in
let equal = Operator.(Equality Equality.Equal) in
let filter_id = Id.create () in
let changelog_id = Changelog.Id.create () in
let firstname name =
Pred (Predicate.create Key.(Hardcoded Firstname) equal (Single (Str name)))
in
let before =
And [ firstname "one"; firstname "two" ] |> create ~id:filter_id None
in
let after =
And [ firstname "one"; firstname "three" ] |> create ~id:filter_id None
in
let changelog =
VersionHistory.create
~id:changelog_id
~entity_uuid:(Id.to_common before.id)
~before
~after
()
in
let expected =
let open Changelog in
let changes =
let open Changes in
Assoc
[ ( "query"
, Assoc
[ ( "and"
, Assoc
[ ( "1"
, Assoc
[ ( "pred"
, Assoc
[ ( "value"
, Assoc
[ ( "str"
, Change (`String "two", `String "three")
)
] )
] )
] )
] )
] )
]
in
Write.
{ id = changelog_id
; changes
; model = Pool_message.Field.Filter
; entity_uuid = Filter.Id.to_common before.id
; user_uuid = None
; created_at = Pool_common.CreatedAt.create_now ()
}
|> CCOption.return
in
Alcotest.(check (option testable_changelog))
"changelog contains name"
changelog
expected
;;
1 change: 1 addition & 0 deletions pool/test/command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let () =
[ test_case "create unchanged" `Quick create_unchanged
; test_case "create" `Quick create
; test_case "create with nested changes" `Quick create_nested
; test_case "create filter changelog" `Quick update_filter
] )
; ( "contact"
, [ test_case
Expand Down

0 comments on commit 0d8daf6

Please sign in to comment.