reifyhealth / specmonstah

Specmonstah will eat the face off your test fixtures
MIT License
359 stars 18 forks source link

core/add-ents validation idea #70

Closed cldwalker closed 4 years ago

cldwalker commented 4 years ago

Hi @flyingmachine. In our test helper fn that wraps spec-gen/ent-db-spec-gen, which in turn wraps core/add-ents, we've added validation to ensure the query doesn't contain any keys/types that don't exist in schema. We've been bitten a couple times where we didn't realize a query contained a nonexistent type. In our case we're at 34 ent types for our schema so perhaps this isn't a common problem for other folks. In any case here's the validation code in case it's helpful:

   (let [diff (set/difference (set (keys query)) (set (keys schema)))]
     (assert (empty? diff)
             (str "The following keys are not valid specmonstah types: " diff)))

Happy to PR if you think it's helpful

flyingmachine commented 4 years ago

This is a very good idea!

flyingmachine commented 4 years ago

added by #71