Mastodon Feed: Post

Mastodon Feed

lloydmeta ("Lloyd") wrote:

If you've ever needed to spin up resources outside your rust process that you want to share _between_ tests via static bindings that need to be cleaned up and run into the "`drop` doesn't just work with static" problem ...

This concoction with ctor and channels might help:

https://github.com/lloydmeta/miniaturs/blob/d244760f5039a15450f5d4566ffe52d19d427771/server/src/test_utils/mod.rs#L12-L113

Credit goes to those who pointed out this pattern in the testcontainers-rs repo.

It does lean a bit more to the "chaotic good" side, if custom test harness is "lawful good" 🤣.

#rustlang