Skip to content

Commit 8e0ab48

Browse files
committed
added a test case
1 parent c65895d commit 8e0ab48

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

env_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ type simpleConfig struct {
132132
Timeout time.Duration `default:"5s" env:"DB_TIMEOUT"`
133133
}
134134

135+
type pigPort struct {
136+
Port uint16 `env:"BIG_PORT" validate:"required"`
137+
}
138+
135139
func TestLoadUsingReflect(t *testing.T) {
136140
// ENV settings PORT=80;DB=db/file;CACHE=5;BADCACHE1=i;BADCACHE2=300
137141
t.Setenv("PORT", "80")
@@ -152,6 +156,7 @@ func TestLoadUsingReflect(t *testing.T) {
152156
t.Setenv("HAS_DB", "true")
153157
t.Setenv("DOMAIN", "3lines.club")
154158
t.Setenv("EMAIL", "email@3lines.club")
159+
t.Setenv("BIG_PORT", "25060")
155160

156161
var goodSettings1 goodEnvironmentSettings1
157162
var goodSettings3withEmptyString goodEnvironmentSettings3withEmptyString
@@ -198,6 +203,7 @@ func TestLoadUsingReflect(t *testing.T) {
198203
{"not_set_env", &simple, nil},
199204
{"omitted field", &settingsWithStruct3{}, nil},
200205
{"an example", &Settings{}, nil},
206+
{"big port", &pigPort{}, nil},
201207
}
202208

203209
var err error
@@ -210,6 +216,7 @@ func TestLoadUsingReflect(t *testing.T) {
210216

211217
t.Run(tt.name, func(t *testing.T) {
212218
err = Load(tt.settings)
219+
t.Logf("settings: %v", tt.settings)
213220

214221
if errors.Is(err, tt.wantErr) {
215222
if err != nil {

0 commit comments

Comments
 (0)