From e2a1726626b225c4a879b2b31f486ce5be5a7280 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 2 Jan 2024 08:34:39 +0100 Subject: [PATCH] Try writing some tests --- micronfig/src/lib.rs | 2 ++ micronfig_macros/Cargo.toml | 4 ++++ micronfig_macros/tests/configs/01-three-strings.rs | 7 +++++++ micronfig_macros/tests/configs/02-zero-strings.rs | 3 +++ micronfig_macros/tests/trybuild.rs | 5 +++++ 5 files changed, 21 insertions(+) create mode 100644 micronfig_macros/tests/configs/01-three-strings.rs create mode 100644 micronfig_macros/tests/configs/02-zero-strings.rs create mode 100644 micronfig_macros/tests/trybuild.rs diff --git a/micronfig/src/lib.rs b/micronfig/src/lib.rs index 328d9b0..3ae1096 100644 --- a/micronfig/src/lib.rs +++ b/micronfig/src/lib.rs @@ -6,3 +6,5 @@ pub mod envvars; pub mod envfiles; #[cfg(feature = "envdot")] pub mod envdot; + +pub use micronfig_macros::config; diff --git a/micronfig_macros/Cargo.toml b/micronfig_macros/Cargo.toml index 656dfc6..842ec42 100644 --- a/micronfig_macros/Cargo.toml +++ b/micronfig_macros/Cargo.toml @@ -17,5 +17,9 @@ rustdoc-args = ["--document-private-items"] syn = "2.0" quote = "1.0" +[dev-dependencies] +trybuild = "1.0" +micronfig = { version = "0.3.0", path = "../micronfig" } + [lib] proc-macro = true diff --git a/micronfig_macros/tests/configs/01-three-strings.rs b/micronfig_macros/tests/configs/01-three-strings.rs new file mode 100644 index 0000000..8044b7a --- /dev/null +++ b/micronfig_macros/tests/configs/01-three-strings.rs @@ -0,0 +1,7 @@ +use micronfig; + +config! { + GARAS: String, + AUTO: String, + BUS: String, +} diff --git a/micronfig_macros/tests/configs/02-zero-strings.rs b/micronfig_macros/tests/configs/02-zero-strings.rs new file mode 100644 index 0000000..cd5a9eb --- /dev/null +++ b/micronfig_macros/tests/configs/02-zero-strings.rs @@ -0,0 +1,3 @@ +use micronfig; + +config! {} diff --git a/micronfig_macros/tests/trybuild.rs b/micronfig_macros/tests/trybuild.rs new file mode 100644 index 0000000..12ddc35 --- /dev/null +++ b/micronfig_macros/tests/trybuild.rs @@ -0,0 +1,5 @@ +#[test] +fn trybuild() { + let t = trybuild::TestCases::new(); + t.pass("tests/configs/*.rs"); +}