You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
425 B

  1. package util
  2. import (
  3. "os"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestAllKeysWithEnv(t *testing.T) {
  8. v := GetViper()
  9. v.BindEnv("id")
  10. v.BindEnv("foo", "foo")
  11. // bind and define environment variables (including a nested one)
  12. os.Setenv("WEED_ID", "13")
  13. os.Setenv("WEED_FOO_BAR", "baz")
  14. sub := v.Sub("foo")
  15. assert.Equal(t, "13", v.GetString("id"))
  16. assert.Equal(t, "baz", sub.GetString("bar"))
  17. }