Introduce a procedural macro for Nexus-specific tests#502
Conversation
This handles setup and teardown of our test contexts
|
Looks great. Looks like there are still some teardown calls that could be removed. |
|
Most of the remaining ones aren't for ControlPlaneTestContext. There's one case left that I know if, and it can't be migrated to the new thing because it needs the ControlPlaneTestContext to be mutable because it mucks with the |
|
Oh, I misremembered how Rust borrows work with structs. The oximeter test (the one that mucks with fields of the context) can't be migrated to use this macro since it must own the context |
|
I love this -- and especially that it also makes sure the name is set usefully. I often copy/paste those and forget to fix them. |
Yeah, me too |
| cptestctx.teardown().await; | ||
| } | ||
|
|
||
| #[tokio::test] |
There was a problem hiding this comment.
do these need to be converted to #[nexus_test]?
There was a problem hiding this comment.
yes, thank you! Looks like I somehow only partially migrated this file
| cptestctx.teardown().await; | ||
| } | ||
|
|
||
| #[tokio::test] |
There was a problem hiding this comment.
not this one because I'm using a custom config, I think
| [dev-dependencies] | ||
| criterion = { version = "0.3", features = [ "async_tokio" ] } | ||
| expectorate = "1.0.4" | ||
| nexus-test-utils-macros = { path = "test-utils-macros" } |
There was a problem hiding this comment.
Is this one of the macros that has to be in its own crate? If so, we may as well give it a more specific crate name. If not, can we just put it into necus/test-utils?
There was a problem hiding this comment.
Yeah, proc macros have to be the only thing in their crate (though you can have as many as you want in it). I believe if you try to set proc-macro = true in the Cargo.toml in a crate with other public things in it, you get an error
|
Sorry -- I thought I had submitted several comments earlier but they were still "pending" -- I guess I just separately left a single top-level comment. Anyway, you resolved most of them already. I had one nit about the crate name but feel free to land as-is if you prefer. |
This handles setup and teardown of
ControlPlaneTestContexts, ensuring developers don't forget to call teardown.I'm trying to think of ways we might genericize this a bit to support some of the other setup/teardown patterned objects in our tests