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...
no, it's passing it into the :fn
verifier
sorry wasn't clear. stest/check is passing the generated data to the actual function
but that data is slightly deformed via conform to the actual :fn
checker
Oh, right. So you're trying to rely on input metadata in the :fn
verifier?
(per the labeling)
yea
I wouldn't expect metadata to be preserved through that. It doesn't seem like something you should be relying on in :fn
.
it would be very useful for testing purposes
the generators can then inform the tests what the expected behavior should be
I can't imagine any better way to accomplish that in fact
and as long as the generators don't use s/alt
s/cat
and the like, this is entirely possible
(i've done it previously)
i have to step out now so will respond back later this evening. thx
Could you use s/conformer
in the spec to thread the metadata into the conformed result I wonder?