-
-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use non-inline modules in a proc macro (second attempt to move tests to separate file) #1632
Comments
This almost works for the contents of use pgrx::prelude::*;
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod gotest {
#[pg_test]
fn test_hello_separate_tests() {
assert_eq!("Hello, separate_tests", crate::hello_separate_tests());
}
}
/// This module is required by `cargo pgrx test` invocations.
/// It must be visible at the root of your extension crate.
#[cfg(test)]
pub mod pg_test {
pub fn setup(_options: Vec<&str>) {
// perform one-off initialization when the pg_test framework starts
}
pub fn postgresql_conf_options() -> Vec<&'static str> {
// return any postgresql.conf settings that are required for your tests
vec![]
}
} The only error is from
It works if I use |
Hmm, this should be #[cfg(test)]
mod tests; This doesn't matter, however. Interesting. A comment in the
This requires the test module to contain: mod gotest {
use super::*; Because the prelude of pgrx is not automatically visible inside submodules inside a file. |
I think it could be if I named the file
After my original post I got as far as a single issue by adding
Amusingly I get exactly the same error if I |
That is not the case. Are you writing this somewhere other than lib.rs? Modules are hierarchical. You may find reading fasterthanlime's article helpful. |
Okay I just removed the
I am not.
🔖ed! |
In follow-up to #1631, I followed the second example in this Discord post, setting up the test module like so:
And the contents of
tests.rs
are:But the compiler complains:
The errors go away if I remove
#![pg_schema]
and change thetest_hello_separate_tests
from#[pg_test]
to#[test]
.The text was updated successfully, but these errors were encountered: