Skip to content

Commit 68df708

Browse files
committed
Add unit test to the new db_get_by_uuid_opt function
Signed-off-by: Vincent Liu <[email protected]>
1 parent 99496a9 commit 68df708

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ocaml/database/database_test.ml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,24 @@ functor
580580
let (_ : string) = Client.db_get_by_uuid t "VM" invalid_uuid in
581581
failwith "db_get_by_uuid <invalid uuid>"
582582
) ;
583+
Printf.printf "db_get_by_uuid_opt <valid uuid>\n" ;
584+
let r = Client.db_get_by_uuid_opt t "VM" valid_uuid in
585+
( if r <> Some valid_ref then
586+
let rs = Option.fold ~none:"None" ~some:Fun.id r in
587+
failwith
588+
(Printf.sprintf
589+
"db_get_by_uuid_opt <valid uuid>: got %s; expected %s" rs
590+
valid_ref
591+
)
592+
) ;
593+
Printf.printf "db_get_by_uuid_opt <invalid uuid>\n" ;
594+
let r = Client.db_get_by_uuid_opt t "VM" invalid_uuid in
595+
if not (Option.is_none r) then
596+
failwith
597+
(Printf.sprintf
598+
"db_get_by_uuid_opt <invalid uuid>: got %s; expected None"
599+
valid_ref
600+
) ;
583601
Printf.printf "get_by_name_label <invalid name label>\n" ;
584602
if Client.db_get_by_name_label t "VM" invalid_name <> [] then
585603
failwith "db_get_by_name_label <invalid name label>" ;

0 commit comments

Comments
 (0)