aboutsummaryrefslogtreecommitdiff
path: root/lib/fixture.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2023-12-26 10:46:11 -0600
committerMarc Coquand <marc@mccd.space>2023-12-26 10:46:11 -0600
commit2a664a47c73e232b6ff0d261833e2561d4abc4d0 (patch)
tree8ad1f0c88f6151bff69f63d61e1e447d2ae5b034 /lib/fixture.ml
parentd96e1839eb800bf26bcc38272072d98af69f5d83 (diff)
downloadfixgen-2a664a47c73e232b6ff0d261833e2561d4abc4d0.tar.gz
fixgen-2a664a47c73e232b6ff0d261833e2561d4abc4d0.tar.bz2
fixgen-2a664a47c73e232b6ff0d261833e2561d4abc4d0.zip
Support list
Diffstat (limited to 'lib/fixture.ml')
-rw-r--r--lib/fixture.ml6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/fixture.ml b/lib/fixture.ml
index 2b17a02..d5c77fa 100644
--- a/lib/fixture.ml
+++ b/lib/fixture.ml
@@ -25,9 +25,10 @@ let%test "random_name" = List.mem (random_name ()) names
type t =
| Name of string
| Uuidv4 of string
- | Foreign of (string * string list)
+ | Foreign of string * string list
| Int of string * int * int
| Const of string * string
+ | List of string * string list
(* (Name, foreign ids to pick from) *)
let add_name name fixtures = Name name :: fixtures
@@ -48,6 +49,7 @@ let generate_fixture fixture =
| Foreign (_, reference) -> random_value_in_list reference
| Const (_, value) -> value
| Int (_, min, max) -> Random.int (max - min) + min |> string_of_int
+ | List (_, values) -> random_value_in_list values
let%test "generate_uuid" =
@@ -61,10 +63,10 @@ let id_of_fixture fixture =
| Foreign (id, _) -> id
| Const (id, _) -> id
| Int (id, _, _) -> id
+ | List (id, _) -> id
(* TODO: Support email *)
-(* TODO: Support list *)
let rec replicate element n =
match n with