@@ -48,17 +48,35 @@ func TestFromEnv(t *testing.T) {
4848 io Validator
4949 error bool
5050 }{
51- {"nil" , EnvOptions {}, nil , true },
52- {"nonptr" , EnvOptions {}, simpleValidator {}, true },
53- {"nilptr" , EnvOptions {}, (* simpleValidator )(nil ), true },
54- {"defaulterr" , EnvOptions {}, new (nonStructValidator ), true },
55- {"parseeerr" , EnvOptions {Environment : map [string ]string {"FOO" : "bar" }}, & simpleValidator {}, true },
56- {"invalid" , EnvOptions {Environment : map [string ]string {"FOO" : "23" }}, & simpleValidator {}, true },
57- {"simple" , EnvOptions {Environment : map [string ]string {"FOO" : "42" }}, & simpleValidator {42 }, false },
58- {"default" , EnvOptions {}, & defaultValidator {42 }, false },
59- {"override" , EnvOptions {Environment : map [string ]string {"FOO" : "23" }}, & defaultValidator {23 }, false },
60- {"prefix" , EnvOptions {Environment : map [string ]string {"PREFIX_FOO" : "42" }, Prefix : "PREFIX_" }, & simpleValidator {42 }, false },
61- {"nested" , EnvOptions {Environment : map [string ]string {"PREFIX_FOO" : "42" }}, & prefixValidator {simpleValidator {42 }}, false },
51+ {name : "nil" , error : true },
52+ {name : "nonptr" , io : simpleValidator {}, error : true },
53+ {name : "nilptr" , io : (* simpleValidator )(nil ), error : true },
54+ {name : "defaulterr" , io : new (nonStructValidator ), error : true },
55+ {
56+ name : "parseeerr" ,
57+ opts : EnvOptions {Environment : map [string ]string {"FOO" : "bar" }},
58+ io : & simpleValidator {},
59+ error : true ,
60+ },
61+ {
62+ name : "invalid" ,
63+ opts : EnvOptions {Environment : map [string ]string {"FOO" : "23" }},
64+ io : & simpleValidator {},
65+ error : true ,
66+ },
67+ {name : "simple" , opts : EnvOptions {Environment : map [string ]string {"FOO" : "42" }}, io : & simpleValidator {42 }},
68+ {name : "default" , io : & defaultValidator {42 }},
69+ {name : "override" , opts : EnvOptions {Environment : map [string ]string {"FOO" : "23" }}, io : & defaultValidator {23 }},
70+ {
71+ name : "prefix" ,
72+ opts : EnvOptions {Environment : map [string ]string {"PREFIX_FOO" : "42" }, Prefix : "PREFIX_" },
73+ io : & simpleValidator {42 },
74+ },
75+ {
76+ name : "nested" ,
77+ opts : EnvOptions {Environment : map [string ]string {"PREFIX_FOO" : "42" }},
78+ io : & prefixValidator {simpleValidator {42 }},
79+ },
6280 }
6381
6482 for _ , st := range subtests {
0 commit comments