Hi guys! I have this schema:
(def s
[:map
[:x :string]
[:y {:optional true :gen/return "hello"} :string]]
I'm wondering if there is a way to force the field y be always generate with malli.genif it always generates :y, when do you test that it doesn't exist?
Yes maybe not always
I mean that the purpose of test generation is to test all permutations of the potential data. if you want to cover the part where it doesn't do that, maybe generate only the :x schema and add in the :y schema after
I think the gen should be attached to the string and not the map entry
Not supported at the moment IIRC, either use :gen/fmap to assoc the entry back on or :gen/schema to override the entire schema. It would be easy to support a :gen/optional field on the map entry, please open a ticket if you're interested in that.
(def s
[:map
{:gen/schema [:map [:x :string] [:y :string]]}
[:x :string]
[:y {:optional true} :string]]
(ideally this would be supported:)
(def s
[:map
[:x :string]
[:y {:optional true :gen/optional false} :string]]