to Config struct for configging
This commit is contained in:
23
config_test.go
Normal file
23
config_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNewConfig(t *testing.T) {
|
||||
if got, err := newConfigFromEnv(func(k string) string {
|
||||
t.Logf("getenv(%s)", k)
|
||||
switch k {
|
||||
case "PORT":
|
||||
return "1"
|
||||
case "A_B":
|
||||
return "2"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if got.Port != 1 {
|
||||
t.Error(got)
|
||||
} else if got.AB != "2" {
|
||||
t.Error(got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user