MCPcopy Create free account
hub / github.com/caarlos0/env / TestIssue298ErrorNestedFieldRequiredNotSet

Function TestIssue298ErrorNestedFieldRequiredNotSet

env_test.go:2192–2207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2190}
2191
2192func 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
2209func TestIssue320(t *testing.T) {
2210 type Test struct {

Callers

nothing calls this directly

Calls 4

ParseFunction · 0.85
isErrorWithMessageFunction · 0.85
isTrueFunction · 0.85
IsMethod · 0.80

Tested by

no test coverage detected