diff options
author | Marc Coquand <marc@mccd.space> | 2023-12-26 18:20:17 -0600 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2023-12-26 18:20:17 -0600 |
commit | 1bfdc164a42a16f86d02f0423450a5439dd3d61c (patch) | |
tree | 06be4720df4c932c6b54a3caa916e3db9fe22960 /lib | |
parent | 5980ac3c5825f95f3040d9264c2ec3b369f33db2 (diff) | |
download | fixgen-1bfdc164a42a16f86d02f0423450a5439dd3d61c.tar.gz fixgen-1bfdc164a42a16f86d02f0423450a5439dd3d61c.tar.bz2 fixgen-1bfdc164a42a16f86d02f0423450a5439dd3d61c.zip |
Each name and email is unique
Using index
Diffstat (limited to '')
-rw-r--r-- | lib/fixture.ml | 10 |
1 files 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 @ *) |