From b2510470691b71695996144a272f79ee5ed4a77a Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 4 Dec 2020 22:44:00 +0300 Subject: [PATCH] complete Signed-off-by: Vasiliy Tolstov --- env_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/env_test.go b/env_test.go index 94970cc..7f30dae 100644 --- a/env_test.go +++ b/env_test.go @@ -6,7 +6,6 @@ import ( "testing" "context" "os" - "fmt" ) type Config struct { @@ -15,6 +14,7 @@ type Config struct { StringSlice []string `env:"STRING_SLICE"` IntSlice []int `env:"INT_SLICE"` MapStringValue map[string]string `env:"MAP_STRING"` + MapIntValue map[string]int `env:"MAP_INT"` } func TestEnv(t *testing.T) { @@ -40,6 +40,7 @@ func TestEnv(t *testing.T) { os.Setenv("STRING_SLICE", "STRING_SLICE1,STRING_SLICE2;STRING_SLICE3") os.Setenv("INT_SLICE", "1,2,3,4,5") os.Setenv("MAP_STRING", "key1=val1,key2=val2") + os.Setenv("MAP_INT", "key1=1,key2=2") if err := cfg.Load(ctx); err !=nil { t.Fatal(err) @@ -56,5 +57,12 @@ func TestEnv(t *testing.T) { t.Fatalf("something wrong with env config: %v", conf) } - fmt.Printf("%#+v\n", conf) + if len(conf.MapStringValue) != 2 { + t.Fatalf("something wrong with env config: %v", conf) + } + + if len(conf.MapIntValue) != 2 { + t.Fatalf("something wrong with env config: %v", conf) + } + }