Merge pull request 'update to uuidm 0.9.9 deprecations' (!4) from update-uuidm into main

Reviewed-on: #4
Reviewed-by: Reynir Björnsson <reynir@reynir.dk>
This commit is contained in:
Reynir Björnsson 2024-12-17 11:15:18 +00:00
commit 75f337b995
4 changed files with 13 additions and 12 deletions

View file

@ -6,9 +6,9 @@ and rollback_doc = "switch uuid encoding back to binary"
open Grej.Infix open Grej.Infix
let old_uuid_rep = let old_uuid_rep =
let encode uuid = Ok (Uuidm.to_bytes uuid) in let encode uuid = Ok (Uuidm.to_binary_string uuid) in
let decode s = let decode s =
Uuidm.of_bytes s Uuidm.of_binary_string s
|> Option.to_result ~none:"failed to decode uuid" |> Option.to_result ~none:"failed to decode uuid"
in in
Caqti_type.custom ~encode ~decode Caqti_type.string Caqti_type.custom ~encode ~decode Caqti_type.string

View file

@ -49,6 +49,7 @@ depends: [
"solo5-elftool" {>= "0.3.0"} "solo5-elftool" {>= "0.3.0"}
"decompress" {>= "1.5.0"} "decompress" {>= "1.5.0"}
"digestif" {>= "1.2.0"} "digestif" {>= "1.2.0"}
"uuidm" {>= "0.9.9"}
"alcotest" {>= "1.2.0" & with-test} "alcotest" {>= "1.2.0" & with-test}
"ppx_deriving" {with-test} "ppx_deriving" {with-test}
"ppx_deriving_yojson" {with-test} "ppx_deriving_yojson" {with-test}

View file

@ -85,7 +85,7 @@ let test_link method_ target () =
let test_link_artifact artifact = let test_link_artifact artifact =
let job_name = "test" in let job_name = "test" in
let build = Uuidm.v `V4 in let build = Uuidm.v4_gen (Random.State.make_self_init ()) () in
test_link `GET @@ test_link `GET @@
Builder_web.Link.Job_build_artifact.make ~job_name ~build ~artifact () Builder_web.Link.Job_build_artifact.make ~job_name ~build ~artifact ()
@ -108,12 +108,12 @@ let () =
end; end;
test_case "Link.Job_build.make" `Quick begin test_case "Link.Job_build.make" `Quick begin
let job_name = "test" in let job_name = "test" in
let build = Uuidm.v `V4 in let build = Uuidm.v4_gen (Random.State.make_self_init ()) () in
test_link `GET @@ Builder_web.Link.Job_build.make ~job_name ~build () test_link `GET @@ Builder_web.Link.Job_build.make ~job_name ~build ()
end; end;
test_case "Link.Job_build_artifact.make_from_string" `Quick begin test_case "Link.Job_build_artifact.make_from_string" `Quick begin
let job_name = "test" in let job_name = "test" in
let build = Uuidm.v `V4 in let build = Uuidm.v4_gen (Random.State.make_self_init ()) () in
let artifact = "" in let artifact = "" in
test_link `GET @@ test_link `GET @@
Builder_web.Link.Job_build_artifact.make_from_string Builder_web.Link.Job_build_artifact.make_from_string
@ -140,8 +140,8 @@ let () =
) )
) @ Alcotest.[ ) @ Alcotest.[
test_case "Link.Compare_builds.make" `Quick begin test_case "Link.Compare_builds.make" `Quick begin
let left = Uuidm.v `V4 in let left = Uuidm.v4_gen (Random.State.make_self_init ()) () in
let right = Uuidm.v `V4 in let right = Uuidm.v4_gen (Random.State.make_self_init ()) () in
test_link `GET @@ test_link `GET @@
Builder_web.Link.Compare_builds.make ~left ~right () Builder_web.Link.Compare_builds.make ~left ~right ()
end; end;
@ -177,12 +177,12 @@ let () =
end; end;
begin begin
let job = "foo" in let job = "foo" in
let build = Uuidm.(v `V4 |> to_string) in let build = Uuidm.(v4_gen (Random.State.make_self_init ()) () |> to_string) in
"/job/" ^ job ^ "/build/" ^ build ^ "/main-binary" "/job/" ^ job ^ "/build/" ^ build ^ "/main-binary"
end; end;
begin begin
let old_uuid = Uuidm.(v `V4 |> to_string) in let old_uuid = Uuidm.(v4_gen (Random.State.make_self_init ()) () |> to_string) in
let new_uuid = Uuidm.(v `V4 |> to_string) in let new_uuid = Uuidm.(v4_gen (Random.State.make_self_init ()) () |> to_string) in
Fmt.str "/compare/%s/%s" old_uuid new_uuid Fmt.str "/compare/%s/%s" old_uuid new_uuid
end; end;
] ]

View file

@ -123,7 +123,7 @@ let test_user_unauth (module Db : CONN) =
let job_name = "test-job" let job_name = "test-job"
let script = Fpath.v "/dev/null" let script = Fpath.v "/dev/null"
let uuid = Uuidm.v `V4 let uuid = Uuidm.v4_gen (Random.State.make_self_init ()) ()
let console = Fpath.v "/dev/null" let console = Fpath.v "/dev/null"
let start = Option.get (Ptime.of_float_s 0.) let start = Option.get (Ptime.of_float_s 0.)
let finish = Option.get (Ptime.of_float_s 1.) let finish = Option.get (Ptime.of_float_s 1.)
@ -195,7 +195,7 @@ let test_build_get_all (module Db : CONN) =
Db.collect_list Builder_db.Build.get_all job_id >>| fun builds -> Db.collect_list Builder_db.Build.get_all job_id >>| fun builds ->
Alcotest.(check int) "one build" (List.length builds) 1 Alcotest.(check int) "one build" (List.length builds) 1
let uuid' = Uuidm.v `V4 let uuid' = Uuidm.v4_gen (Random.State.make_self_init ()) ()
let start' = Option.get (Ptime.of_float_s 3600.) let start' = Option.get (Ptime.of_float_s 3600.)
let finish' = Option.get (Ptime.of_float_s 3601.) let finish' = Option.get (Ptime.of_float_s 3601.)