This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-09
Channels
- # announcements (4)
- # babashka (2)
- # beginners (8)
- # calva (2)
- # chlorine-clover (7)
- # cider (3)
- # clj-kondo (1)
- # cljs-dev (2)
- # clojure (21)
- # clojure-dev (2)
- # clojure-europe (5)
- # clojure-spec (17)
- # clojuredesign-podcast (7)
- # clojurescript (8)
- # conjure (4)
- # cursive (3)
- # datomic (1)
- # defnpodcast (5)
- # esprit (51)
- # fulcro (7)
- # jobs (1)
- # luminus (3)
- # news-and-articles (1)
- # off-topic (2)
- # other-lisps (3)
- # pathom (8)
- # portal (3)
- # re-frame (3)
- # re-ops (1)
- # shadow-cljs (26)
- # testing (15)
- # tools-deps (34)
- # xtdb (1)
hi, i have a spec'd function that is taking as input a collection of data where the individual elements have attached metadata via a with-gen
for their spec. however, because stest/check
conforms these inputs to their constituent components (specified via s/cat
) the metadata which was attached to the outer element is lost. what is the recommended way around this? perhaps a way to override "conform" or otherwise propagate the metadata? something else?
i could manually attach the metadata rather than to the outer value to one of its constituents but this doesn't feel like the proper data modeling for the actual situation. i could also add an extra component to the s/alt
but that isn't desirable as it would expose "test-only" data to the code under test (and also generally violate one's tastes with respect to the actual modeling).
@johanatan Are you saying that stest/check
is passing conformed data into the function under test? That doesn't seem right since the conformed shape won't necessarily match the input shape...
sorry wasn't clear. stest/check is passing the generated data to the actual function
Oh, right. So you're trying to rely on input metadata in the :fn
verifier?
I wouldn't expect metadata to be preserved through that. It doesn't seem like something you should be relying on in :fn
.
and as long as the generators don't use s/alt
s/cat
and the like, this is entirely possible
Could you use s/conformer
in the spec to thread the metadata into the conformed result I wonder?