(t *testing.T)
| 2190 | } |
| 2191 | |
| 2192 | func TestIssue298ErrorNestedFieldRequiredNotSet(t *testing.T) { |
| 2193 | type Test struct { |
| 2194 | Str string `env:"STR,required"` |
| 2195 | Num int `env:"NUM"` |
| 2196 | } |
| 2197 | type ComplexConfig struct { |
| 2198 | Foo *[]Test `envPrefix:"FOO"` |
| 2199 | } |
| 2200 | |
| 2201 | t.Setenv("FOO_0_NUM", "101") |
| 2202 | |
| 2203 | cfg := ComplexConfig{} |
| 2204 | err := Parse(&cfg) |
| 2205 | isErrorWithMessage(t, err, `env: required environment variable "FOO_0_STR" is not set`) |
| 2206 | isTrue(t, errors.Is(err, VarIsNotSetError{})) |
| 2207 | } |
| 2208 | |
| 2209 | func TestIssue320(t *testing.T) { |
| 2210 | type Test struct { |
nothing calls this directly
no test coverage detected