Fork me on GitHub
#crux
<
2021-02-24
>
Aleksander Rendtslev16:02:45

Are there any good examples of how to do testing with crux?

Steven Deobald16:02:09

Testing like acceptance tests, integration tests, and e2e tests which are testing with Crux in the flow? Or unit tests which avoid hitting Crux?

Steven Deobald16:02:34

Also, are you wondering more about environmental setup? Or how to write the tests themselves? Or both?

Aleksander Rendtslev16:02:46

Tests that do hit crux. I just want some simple tests to verify that my queries return what I expect them to. So I seed the DB with some data, and query against it.

Aleksander Rendtslev16:02:39

I’ve created a test-db with the inmemory db that seems to do the trick. That’s probably fine. I just couldn’t find any examples of it

refset17:02:38

^ that's essentially how we do things throughout much of the tests in the repo. These are particularly clear examples (without the indirection of various test fixture namespaces): https://github.com/juxt/crux/blob/d8f251c2f9b3930453239681de1ed87e636ff2a3/crux-core/test/crux/codec_test.clj#L194-L202 https://github.com/juxt/crux/blob/224a3dc04b0b9d9d5336c54f0ea9ee0d0aeb003b/crux-test/test/crux/bitemporal_tale_test.clj#L6

Aleksander Rendtslev17:02:37

Neat! Would be nice with that in a quick example. The one thing I was missing was the with-open function. Makes a lot of sense to use that

Steven Deobald20:02:46

@U01DH13SK8E Out of curiosity, if the answer to your question had been in the documentation, where would you expect/hope to find it? We'll be adding a cluster of How-To Guides to the docs soon... would that be the best home for it, in your opinion? (I'd like to make sure we cover this case.)

Aleksander Rendtslev23:02:42

That would probably be the perfect place. A simple Testing topic would be what I’d be looking for. How do I test with Crux? What do you recommend I test? What do you recommend I don’t test?

🙏 1
Steven Deobald23:02:14

Cool beans. We'll make sure that gets included as we're iterating on the How-Tos. Thanks!

Aleksander Rendtslev00:02:46

Thank you for being so responsive in here! It constantly reinforces my confidence in working with your solutions

😊 1