Skip to content

Commit 3c1eb77

Browse files
johnelserobhoes
authored andcommitted
CP-14804: Add tests for Datamodel_utils.has_been_removed
Signed-off-by: John Else <[email protected]>
1 parent a3779fa commit 3c1eb77

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

ocaml/test/OMakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ OCAML_OBJS = \
3030
test_common \
3131
test_basic \
3232
test_helpers \
33+
test_datamodel_utils \
3334
test_db_lowlevel \
3435
test_http \
3536
test_pool_db_backup \

ocaml/test/suite.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ let base_suite =
2121
[
2222
Test_basic.test;
2323
Test_helpers.test;
24+
Test_datamodel_utils.test;
2425
Test_db_lowlevel.test;
2526
Test_http.test;
2627
Test_pool_db_backup.test;

ocaml/test/test_datamodel_utils.ml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
(*
2+
* Copyright (C) Citrix Systems Inc.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
open Fun
16+
open OUnit
17+
open Test_highlevel
18+
19+
module HasBeenRemoved = Generic.Make(struct
20+
module Io = struct
21+
type input_t = Datamodel_types.lifecycle_transition list
22+
type output_t = bool
23+
24+
let string_of_input_t input =
25+
List.map
26+
(fun (lifecycle_change, _, _) ->
27+
Datamodel_types.rpc_of_lifecycle_change lifecycle_change
28+
|> Rpc.to_string)
29+
input
30+
|> String.concat "; "
31+
32+
let string_of_output_t = string_of_bool
33+
end
34+
35+
let transform = Datamodel_utils.has_been_removed
36+
37+
let tests = Datamodel_types.([
38+
[], false;
39+
[Published, "release1", ""], false;
40+
[Removed, "release1", ""], true;
41+
[
42+
Published, "release1", "";
43+
Deprecated, "release2", "";
44+
Removed, "release3", "";
45+
], true;
46+
[
47+
Published, "release1", "";
48+
Deprecated, "release2", "";
49+
Removed, "release3", "";
50+
Published, "release4", "";
51+
], false;
52+
])
53+
end)
54+
55+
let test =
56+
"datamodel_utils" >:::
57+
[
58+
"test_has_been_removed" >::: HasBeenRemoved.tests;
59+
]

0 commit comments

Comments
 (0)