From 1bfdc164a42a16f86d02f0423450a5439dd3d61c Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Tue, 26 Dec 2023 18:20:17 -0600 Subject: Each name and email is unique Using index --- lib/fixture.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fixture.ml b/lib/fixture.ml index dbd6297..18e2ff6 100644 --- a/lib/fixture.ml +++ b/lib/fixture.ml @@ -67,8 +67,8 @@ let show_compiled_csv fixture = | Float f -> string_of_float f -let random_email () = - random_value_in_list email_handles ^ "@" ^ random_value_in_list email_hosts +let random_email index () = + random_value_in_list email_handles ^ index ^ "@" ^ random_value_in_list email_hosts let random_name () = List.nth names (Random.int (List.length names)) @@ -102,13 +102,14 @@ type t = (* (Name, foreign ids to pick from) *) let generate_fixture index fixture = + let str_index = string_of_int index in match fixture with - | Name _ -> String (random_name ()) + | Name _ -> String (random_name () ^ str_index) | Uuidv4 _ -> String (Uuidm.v `V4 |> Uuidm.to_string) | Foreign (_, reference) -> random_value_in_list reference | Increment _ -> Int (index + 1) | Const (_, value) -> String value - | Email _ -> String (random_email ()) + | Email _ -> String (random_email str_index ()) | Int (_, min, max) -> Int (Random.int (max - min) + min) | List (_, values) -> String (random_value_in_list values) @@ -123,7 +124,6 @@ let%test "random_value_in_list" = List.mem result values -(* TODO: Support email *) (* TODO: Support "hashed" password *) (* TODO: Support dates *) (* TODO: Support variables using @ *) -- cgit v1.2.3