mirror of
https://git.sr.ht/~bryan_bennett/flake_env
synced 2025-12-17 07:01:23 +01:00
Rework hash_files to return (str, str) result
This commit is contained in:
parent
98c3131f7f
commit
6b313a6ff6
3 changed files with 60 additions and 22 deletions
|
|
@ -16,7 +16,22 @@ let _syst_to_bool =
|
|||
|
||||
let check_exit_or_signal =
|
||||
Alcotest.(check(Alcotest.pair(testable_exit_or_signal, string)));
|
||||
let check_string = Alcotest.(check(string));
|
||||
let testable_result_string =
|
||||
Alcotest.testable(
|
||||
(pp_fmt, elem) => {
|
||||
switch (elem) {
|
||||
| Ok(s) => Fmt.pf(pp_fmt, "Ok(%s)", s)
|
||||
| Error(s) => Fmt.pf(pp_fmt, "Error(%s)", s)
|
||||
}
|
||||
},
|
||||
(a, b) =>
|
||||
switch (a, b) {
|
||||
| (Ok(a), Ok(b)) => String.compare(a, b) == 0
|
||||
| (Error(a), Error(b)) => String.compare(a, b) == 0
|
||||
| _ => false
|
||||
},
|
||||
);
|
||||
let check_result_string = Alcotest.(check(testable_result_string));
|
||||
let check_bool = Alcotest.(check(bool));
|
||||
let check_get_args =
|
||||
Alcotest.(
|
||||
|
|
@ -47,26 +62,26 @@ let test_run_process_stdout = () =>
|
|||
);
|
||||
|
||||
let test_hash_one = () => {
|
||||
check_string(
|
||||
check_result_string(
|
||||
"Hash matches",
|
||||
hash_files([|"../LICENSE"|]),
|
||||
"b43cf2e824eb66ba0e8f939c08072a8e307b5e5f",
|
||||
Ok("32b4ac64be805d730745f6bac45a5d95174ebd10"),
|
||||
hash_files([|"spit_version.sh"|]),
|
||||
);
|
||||
};
|
||||
|
||||
let test_hash_multiple = () => {
|
||||
check_string(
|
||||
check_result_string(
|
||||
"Hash matches",
|
||||
hash_files([|"../LICENSE", "../LICENSE"|]),
|
||||
"08304d8baeed02722f81252952b00f6ac011ce0c",
|
||||
Ok("e4c880fc6ab9a1b88e6be18e53fc4cec9f463d1a"),
|
||||
hash_files([|"spit_version.sh", "spit_version.sh"|]),
|
||||
);
|
||||
};
|
||||
|
||||
let test_hash_filters_nonexistent = () => {
|
||||
check_string(
|
||||
check_result_string(
|
||||
"Hash matches",
|
||||
hash_files([|"../LICENSE", "FOOBARBAZ"|]),
|
||||
"b43cf2e824eb66ba0e8f939c08072a8e307b5e5f",
|
||||
Ok("32b4ac64be805d730745f6bac45a5d95174ebd10"),
|
||||
hash_files([|"spit_version.sh", "FOOBARBAZ"|]),
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue