Rename get_builds_and_exclude_the_first
This commit is contained in:
parent
73e1bf81ce
commit
6594c6b912
3 changed files with 9 additions and 9 deletions
|
@ -365,7 +365,7 @@ module Build = struct
|
||||||
ORDER BY b.start_d DESC, b.start_ps DESC
|
ORDER BY b.start_d DESC, b.start_ps DESC
|
||||||
|}
|
|}
|
||||||
|
|
||||||
let get_builds_and_exclude_the_first =
|
let get_builds_excluding_latest_n =
|
||||||
Caqti_type.(tup3 (id `job) (option string) int) ->* Caqti_type.tup2 t file @@
|
Caqti_type.(tup3 (id `job) (option string) int) ->* Caqti_type.tup2 t file @@
|
||||||
{| SELECT b.uuid, b.start_d, b.start_ps, b.finish_d, b.finish_ps,
|
{| SELECT b.uuid, b.start_d, b.start_ps, b.finish_d, b.finish_ps,
|
||||||
b.result_code, b.result_msg, b.console, b.script,
|
b.result_code, b.result_msg, b.console, b.script,
|
||||||
|
|
|
@ -131,7 +131,7 @@ sig
|
||||||
Caqti_request.t
|
Caqti_request.t
|
||||||
val get_builds_older_than :
|
val get_builds_older_than :
|
||||||
([`job] id * string option * Ptime.t, t * file, [ `Many | `One | `Zero ]) Caqti_request.t
|
([`job] id * string option * Ptime.t, t * file, [ `Many | `One | `Zero ]) Caqti_request.t
|
||||||
val get_builds_and_exclude_the_first :
|
val get_builds_excluding_latest_n :
|
||||||
([`job] id * string option * int, t * file, [ `Many | `One | `Zero ]) Caqti_request.t
|
([`job] id * string option * int, t * file, [ `Many | `One | `Zero ]) Caqti_request.t
|
||||||
val get_previous_successful_different_output :
|
val get_previous_successful_different_output :
|
||||||
([`build] id, t, [ `One | `Zero ])
|
([`build] id, t, [ `One | `Zero ])
|
||||||
|
|
|
@ -289,22 +289,22 @@ let test_get_builds_older_than (module Db : CONN) =
|
||||||
Alcotest.(check (list Testable.uuid)) "last builds" builds [ uuid'; uuid ];
|
Alcotest.(check (list Testable.uuid)) "last builds" builds [ uuid'; uuid ];
|
||||||
Ok ()
|
Ok ()
|
||||||
|
|
||||||
let test_builds_and_exclude_the_first (module Db : CONN) =
|
let test_builds_excluding_latest_n (module Db : CONN) =
|
||||||
add_second_build (module Db) >>= fun () ->
|
add_second_build (module Db) >>= fun () ->
|
||||||
Db.find_opt Builder_db.Job.get_id_by_name job_name >>= fail_if_none >>= fun job_id ->
|
Db.find_opt Builder_db.Job.get_id_by_name job_name >>= fail_if_none >>= fun job_id ->
|
||||||
Db.collect_list Builder_db.Build.get_builds_and_exclude_the_first (job_id, None, 1) >>= fun builds ->
|
Db.collect_list Builder_db.Build.get_builds_excluding_latest_n (job_id, None, 1) >>= fun builds ->
|
||||||
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
||||||
Alcotest.(check (list Testable.uuid)) "keep recent build" builds [ uuid ];
|
Alcotest.(check (list Testable.uuid)) "keep recent build" builds [ uuid ];
|
||||||
Db.collect_list Builder_db.Build.get_builds_and_exclude_the_first (job_id, None, 2) >>= fun builds ->
|
Db.collect_list Builder_db.Build.get_builds_excluding_latest_n (job_id, None, 2) >>= fun builds ->
|
||||||
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
||||||
Alcotest.(check (list Testable.uuid)) "keep 2 builds" builds [];
|
Alcotest.(check (list Testable.uuid)) "keep 2 builds" builds [];
|
||||||
Db.collect_list Builder_db.Build.get_builds_and_exclude_the_first (job_id, None, 3) >>= fun builds ->
|
Db.collect_list Builder_db.Build.get_builds_excluding_latest_n (job_id, None, 3) >>= fun builds ->
|
||||||
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
||||||
Alcotest.(check (list Testable.uuid)) "last more builds than we have" builds [];
|
Alcotest.(check (list Testable.uuid)) "last more builds than we have" builds [];
|
||||||
Db.collect_list Builder_db.Build.get_builds_and_exclude_the_first (job_id, None, 0) >>= fun builds ->
|
Db.collect_list Builder_db.Build.get_builds_excluding_latest_n (job_id, None, 0) >>= fun builds ->
|
||||||
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
||||||
Alcotest.(check (list Testable.uuid)) "delete all builds" builds [ uuid'; uuid ];
|
Alcotest.(check (list Testable.uuid)) "delete all builds" builds [ uuid'; uuid ];
|
||||||
Db.collect_list Builder_db.Build.get_builds_and_exclude_the_first (job_id, None, -1) >>= fun builds ->
|
Db.collect_list Builder_db.Build.get_builds_excluding_latest_n (job_id, None, -1) >>= fun builds ->
|
||||||
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
let builds = List.map (fun ({ Builder_db.Build.uuid; _ }, _) -> uuid) builds in
|
||||||
Alcotest.(check (list Testable.uuid)) "test an incomprehensible argument (-1)" builds [ uuid'; uuid ];
|
Alcotest.(check (list Testable.uuid)) "test an incomprehensible argument (-1)" builds [ uuid'; uuid ];
|
||||||
Ok ()
|
Ok ()
|
||||||
|
@ -345,6 +345,6 @@ let () =
|
||||||
];
|
];
|
||||||
"vacuum", [
|
"vacuum", [
|
||||||
test_case "Get builds older than now" `Quick (with_build_db test_get_builds_older_than);
|
test_case "Get builds older than now" `Quick (with_build_db test_get_builds_older_than);
|
||||||
test_case "Get older builds and keep a fixed number of then" `Quick (with_build_db test_builds_and_exclude_the_first);
|
test_case "Get older builds and keep a fixed number of then" `Quick (with_build_db test_builds_excluding_latest_n);
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue