Is there a better way to write this?
(gen/fmap (partial reduce merge)
(gen/vector
(gen/let [id gen/uuid
x (gen/hash-map :name gen/string)]
{id (assoc x :id id)})))
That is, generate maps where the key is the same as the :id
in the map in the value. That works fine and doesn't seem too bad to me — just wondering.if it were me I would be using plumbing and so I'd have this function around to make it slightly cleaner: https://github.com/plumatic/plumbing/blob/6d713472f7324344545aa93597cb2a137b3404b3/src/plumbing/core.cljx#L91
so it becomes (gen/fmap #(map-from-vals :id %) (gen/vector gen-a-map-with-an-id))
which I guess means it also seems natural to me to pull out the map generator and give it a name