oauth2_proxy/env_options_test.go

27 lines
464 B
Go
Raw Normal View History

2014-11-15 04:06:07 +00:00
package main
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
2014-11-15 04:06:07 +00:00
)
type envTest struct {
testField string `cfg:"target_field" env:"TEST_ENV_FIELD"`
}
func TestLoadEnvForStruct(t *testing.T) {
cfg := make(EnvOptions)
cfg.LoadEnvForStruct(&envTest{})
_, ok := cfg["target_field"]
assert.Equal(t, ok, false)
os.Setenv("TEST_ENV_FIELD", "1234abcd")
cfg.LoadEnvForStruct(&envTest{})
v := cfg["target_field"]
assert.Equal(t, v, "1234abcd")
}