Fix enum deserialization from env values

Fixes #31
This commit is contained in:
Lukas Kalbertodt
2023-07-02 10:13:04 +02:00
parent 29a5c05770
commit 4fdfb821dc
2 changed files with 31 additions and 1 deletions

19
tests/env.rs Normal file
View File

@@ -0,0 +1,19 @@
use serde::Deserialize;
use confique::{Config};
#[derive(Debug, Deserialize)]
enum Foo { A, B, C }
#[test]
fn enum_env() {
#[derive(Config)]
struct Conf {
#[config(env = "FOO")]
foo: Foo,
}
std::env::set_var("FOO", "B");
let conf = Conf::builder().env().load();
assert!(matches!(conf, Ok(Conf { foo: Foo::B })));
}