aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2025-01-19 21:50:01 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2025-01-19 21:50:01 -0300
commit919b7f1a81982533ff4ab33730c68313690c2b77 (patch)
tree81ca1f9779a8af22d505cbc34fe2cba5a3c9c72b /test
parentfbb9318eede78561970676c9d98d82e3851aeae5 (diff)
downloadSakura-919b7f1a81982533ff4ab33730c68313690c2b77.tar.gz
Sakura-919b7f1a81982533ff4ab33730c68313690c2b77.zip
cleanup and format
Diffstat (limited to 'test')
-rw-r--r--test/test_relational_engine.ml78
1 files changed, 52 insertions, 26 deletions
diff --git a/test/test_relational_engine.ml b/test/test_relational_engine.ml
index 0c025fe..3092acc 100644
--- a/test/test_relational_engine.ml
+++ b/test/test_relational_engine.ml
@@ -1,38 +1,64 @@
-
let%test _ =
let open Relational_engine.Disk.Executor in
- let stream: history = [{state = _EMPTY_SHA_HASH_; files = StringMap.empty}] in
- let locations: locations = StringMap.empty in
- let ((new_commit, _), _) = Result.get_ok @@ write (List.hd stream) locations ~filename:"trash" @@ Bytes.of_string "abc" in
- let expected_state_hash = "bca39cc55b19274133ce57d0bea1ff794589f025d4bcf670c44d5d2811837830" in
+ let stream : history =
+ [
+ {
+ state = _EMPTY_SHA_HASH_;
+ files = StringMap.empty;
+ references = StringMap.empty;
+ };
+ ]
+ in
+ let locations : locations = StringMap.empty in
+ let (new_commit, _), _ =
+ Result.get_ok
+ @@ write (List.hd stream) locations ~filename:"trash"
+ @@ Bytes.of_string "abc"
+ in
+ let expected_state_hash =
+ "bca39cc55b19274133ce57d0bea1ff794589f025d4bcf670c44d5d2811837830"
+ in
new_commit.state = expected_state_hash
let%test _ =
let open Relational_engine.Disk.Executor in
- let stream: history = [{state = _EMPTY_SHA_HASH_; files = StringMap.empty}] in
- let locations: locations = StringMap.empty in
- let ((new_commit, new_locations), _) = Result.get_ok @@ write (List.hd stream) locations ~filename:"trash" @@ Bytes.of_string "abc" in
+ let stream : history =
+ [
+ {
+ state = _EMPTY_SHA_HASH_;
+ files = StringMap.empty;
+ references = StringMap.empty;
+ };
+ ]
+ in
+ let locations : locations = StringMap.empty in
+ let (new_commit, new_locations), _ =
+ Result.get_ok
+ @@ write (List.hd stream) locations ~filename:"trash"
+ @@ Bytes.of_string "abc"
+ in
let result_test =
let open Relational_engine.Extensions.Option in
let+ new_file_content = StringMap.find_opt "trash" new_commit.files in
- let { values; _ }: Hashes.t = List.hd new_file_content in
+ let { values; _ } : Hashes.t = List.hd new_file_content in
StringMap.find_opt (List.hd values) new_locations
- in match result_test with
- | Some location ->
- print_endline @@ Location.show location;
- location.size = 3 && location.offset = 0L
- | None -> false
+ in
+ match result_test with
+ | Some location ->
+ print_endline @@ Location.show location;
+ location.size = 3 && location.offset = 0L
+ | None -> false
(* let%test _ =
- let open Relational_engine.Planner in
- match Relational_engine.Relation.write_and_retrieve () with
- | Ok (last_commit::_, locations) ->
- begin
- let (first_names, last_names) = (Scan.execute last_commit locations "user/first-name", Scan.execute last_commit locations "user/last-name") in
- let tuples = Join.execute first_names last_names locations in
- let tuples = List.map (fun (a, b) -> Bytes.to_string a, Bytes.to_string b) tuples in
- List.iter (fun (a, b) -> print_endline (Printf.sprintf "(%s, %s)" a b)) tuples;
- true
- end
- | _ ->
- false *)
+ let open Relational_engine.Planner in
+ match Relational_engine.Relation.write_and_retrieve () with
+ | Ok (last_commit::_, locations) ->
+ begin
+ let (first_names, last_names) = (Scan.execute last_commit locations "user/first-name", Scan.execute last_commit locations "user/last-name") in
+ let tuples = Join.execute first_names last_names locations in
+ let tuples = List.map (fun (a, b) -> Bytes.to_string a, Bytes.to_string b) tuples in
+ List.iter (fun (a, b) -> print_endline (Printf.sprintf "(%s, %s)" a b)) tuples;
+ true
+ end
+ | _ ->
+ false *)