Skip to content

Commit

Permalink
CP-49212: Add UT for update datamodel for non-CDN update
Browse files Browse the repository at this point in the history
Signed-off-by: Bengang Yuan <[email protected]>
  • Loading branch information
BengangY committed Jul 15, 2024
1 parent f0eddd5 commit bfe61b7
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions ocaml/tests/test_repository.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

module T = Test_common

let test_introduce_duplicate_name () =
let test_introduce_duplicate_repo_name () =
let __context = T.make_test_database () in
let name_label = "name" in
let name_description = "description" in
Expand All @@ -28,13 +28,20 @@ let test_introduce_duplicate_name () =
Repository.introduce ~__context ~name_label ~name_description ~binary_url
~source_url ~update:true ~gpgkey_path
in
Alcotest.check_raises "test_introduce_duplicate_name"
Alcotest.check_raises "test_introduce_duplicate_repo_name_1"
Api_errors.(Server_error (repository_already_exists, [Ref.string_of ref]))
(fun () ->
Repository.introduce ~__context ~name_label
~name_description:name_description_1 ~binary_url:binary_url_1
~source_url:source_url_1 ~update:true ~gpgkey_path
|> ignore
) ;
Alcotest.check_raises "test_introduce_duplicate_repo_name_2"
Api_errors.(Server_error (repository_already_exists, [Ref.string_of ref]))
(fun () ->
Repository.introduce_bundle ~__context ~name_label
~name_description:name_description_1 ~gpgkey_path
|> ignore
)

let test_introduce_duplicate_binary_url () =
Expand All @@ -51,7 +58,7 @@ let test_introduce_duplicate_binary_url () =
Repository.introduce ~__context ~name_label ~name_description ~binary_url
~source_url ~update:true ~gpgkey_path
in
Alcotest.check_raises "test_introduce_duplicate_name"
Alcotest.check_raises "test_introduce_duplicate_binary_url"
Api_errors.(Server_error (repository_already_exists, [Ref.string_of ref]))
(fun () ->
Repository.introduce ~__context ~binary_url ~name_label:name_label_1
Expand Down Expand Up @@ -83,9 +90,31 @@ let test_introduce_invalid_gpgkey_path () =
|> ignore
)

let test_introduce_duplicate_bundle_repo () =
let __context = T.make_test_database () in
let name_label = "name" in
let name_label_1 = "name1" in
let name_description = "description" in
let name_description_1 = "description1" in
let gpgkey_path = "" in
let ref =
Repository.introduce_bundle ~__context ~name_label ~name_description
~gpgkey_path
in
Alcotest.check_raises "test_introduce_duplicate_bundle_repo"
Api_errors.(Server_error (repository_already_exists, [Ref.string_of ref]))
(fun () ->
Repository.introduce_bundle ~__context ~name_label:name_label_1
~name_description:name_description_1 ~gpgkey_path
|> ignore
)

let test =
[
("test_introduce_duplicate_name", `Quick, test_introduce_duplicate_name)
( "test_introduce_duplicate_repo_name"
, `Quick
, test_introduce_duplicate_repo_name
)
; ( "test_introduce_duplicate_binary_url"
, `Quick
, test_introduce_duplicate_binary_url
Expand All @@ -94,6 +123,10 @@ let test =
, `Quick
, test_introduce_invalid_gpgkey_path
)
; ( "test_introduce_duplicate_bundle_repo"
, `Quick
, test_introduce_duplicate_bundle_repo
)
]

let () =
Expand Down

0 comments on commit bfe61b7

Please sign in to comment.