aboutsummaryrefslogtreecommitdiff
path: root/lib/fixture.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2023-12-26 09:34:58 -0600
committerMarc Coquand <marc@mccd.space>2023-12-26 09:57:20 -0600
commit742c23d7c5d90b681dcbce92846d57042d2ea467 (patch)
treeb6cf10333e15bc7b748744f7c7af805ca77f222c /lib/fixture.ml
parent8ac0e27adc8d14a77427351dede1757999c8c709 (diff)
downloadfixgen-742c23d7c5d90b681dcbce92846d57042d2ea467.tar.gz
fixgen-742c23d7c5d90b681dcbce92846d57042d2ea467.tar.bz2
fixgen-742c23d7c5d90b681dcbce92846d57042d2ea467.zip
Add support for ints
Diffstat (limited to 'lib/fixture.ml')
-rw-r--r--lib/fixture.ml7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/fixture.ml b/lib/fixture.ml
index 189d2fb..8806692 100644
--- a/lib/fixture.ml
+++ b/lib/fixture.ml
@@ -22,12 +22,13 @@ let names =
let random_name () = List.nth names (Random.int (List.length names))
let%test "random_name" = List.mem (random_name ()) names
-(* Support arbitrary amount *)
-(* Support names *)
+(* TODO: Support arbitrary amount *)
+(* TODO: Support names *)
type t =
| Name of string
| Uuidv4 of string
| Foreign of (string * string list)
+ | Int of string * int * int
(* (Name, foreign ids to pick from) *)
let add_name name fixtures = Name name :: fixtures
@@ -46,6 +47,7 @@ let generate_fixture fixture =
| Name _ -> random_name ()
| Uuidv4 _ -> Uuidm.v `V4 |> Uuidm.to_string
| Foreign (_, reference) -> random_value_in_list reference
+ | Int (_, min, max) -> Random.int (max - min) + min |> string_of_int
let%test "generate_uuid" =
@@ -57,6 +59,7 @@ let id_of_fixture fixture =
| Name id -> id
| Uuidv4 id -> id
| Foreign (id, _) -> id
+ | Int (id, _, _) -> id
let rec replicate element n =