1
- use config:: { Config , Environment , Source } ;
2
1
use serde_derive:: Deserialize ;
2
+ use snapbox:: { assert_data_eq, str} ;
3
+
4
+ use config:: { Config , Environment , Source } ;
3
5
4
6
/// Reminder that tests using env variables need to use different env variable names, since
5
7
/// tests can be run in parallel
@@ -474,11 +476,13 @@ fn test_parse_string_and_list_ignore_list_parse_key_case() {
474
476
// using a struct in an enum here to make serde use `deserialize_any`
475
477
#[ derive( Deserialize , Debug ) ]
476
478
#[ serde( tag = "tag" ) ]
479
+ #[ allow( dead_code) ]
477
480
enum TestStringEnum {
478
481
String ( TestString ) ,
479
482
}
480
483
481
484
#[ derive( Deserialize , Debug ) ]
485
+ #[ allow( dead_code) ]
482
486
struct TestString {
483
487
string_val : String ,
484
488
string_list : Vec < String > ,
@@ -503,20 +507,13 @@ fn test_parse_string_and_list_ignore_list_parse_key_case() {
503
507
. build ( )
504
508
. unwrap ( ) ;
505
509
506
- let config : TestStringEnum = config. try_deserialize ( ) . unwrap ( ) ;
510
+ let res = config. try_deserialize :: < TestStringEnum > ( ) ;
507
511
508
- match config {
509
- TestStringEnum :: String ( TestString {
510
- string_val,
511
- string_list,
512
- } ) => {
513
- assert_eq ! ( String :: from( "test,string" ) , string_val) ;
514
- assert_eq ! (
515
- vec![ String :: from( "test" ) , String :: from( "string" ) ] ,
516
- string_list
517
- ) ;
518
- }
519
- }
512
+ assert ! ( res. is_err( ) ) ;
513
+ assert_data_eq ! (
514
+ res. unwrap_err( ) . to_string( ) ,
515
+ str ![ [ r#"invalid type: string "test,string", expected a sequence"# ] ]
516
+ ) ;
520
517
} ,
521
518
) ;
522
519
}
0 commit comments