jacobobryant / biff

A Clojure web framework for solo developers.
https://biffweb.com
MIT License
861 stars 40 forks source link

Document writing a test that roundtrips to xtdb? #192

Closed AndrewWinterman closed 6 months ago

AndrewWinterman commented 6 months ago

Hi there,

I'm just getting started with a biff project and want to write a test that puts a value in the database. Is there a code example that shows a good approach for doing this? E.g. a strategy for avoiding having multiple embedded dbs, how to make simple queries in a test environment, etc.

I noticed that there is an xtdb test in the biff project itself, whose approach i intend to copy.

jacobobryant commented 6 months ago

Yeah, the xtdb test in the Biff repo is basically what I'd recommend. I'll go ahead and copy-paste some of that code over into the starter app's test.clj file.

a strategy for avoiding having multiple embedded dbs

Starting up an in-memory node on my machine only takes about 3ms--having a db-per-test should be fine.

jacobobryant commented 6 months ago

Aaand it's done. See https://github.com/jacobobryant/biff/discussions/193, specifically https://github.com/jacobobryant/biff/commit/146f2b1c8e0563bd288795851beae8b985cacac7. That also includes examples of generating random test data with Malli.