diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-01-29 09:09:55 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-01-29 09:09:55 -0800 |
| commit | d335f04de6861b571190c13bd7d65e9a0c02f187 (patch) | |
| tree | ad534357d50c4027718a7fe2e60391b6545a7db0 /weed/util/config_test.go | |
| parent | 27b94cb65b34c084790f0a1884956702ee51acc2 (diff) | |
| download | seaweedfs-d335f04de6861b571190c13bd7d65e9a0c02f187.tar.xz seaweedfs-d335f04de6861b571190c13bd7d65e9a0c02f187.zip | |
support env variables to overwrite toml file
Diffstat (limited to 'weed/util/config_test.go')
| -rw-r--r-- | weed/util/config_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/weed/util/config_test.go b/weed/util/config_test.go new file mode 100644 index 000000000..659814a4a --- /dev/null +++ b/weed/util/config_test.go @@ -0,0 +1,24 @@ +package util + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestAllKeysWithEnv(t *testing.T) { + + v := GetViper() + v.BindEnv("id") + v.BindEnv("foo", "foo") + + // bind and define environment variables (including a nested one) + os.Setenv("WEED_ID", "13") + os.Setenv("WEED_FOO_BAR", "baz") + + sub := v.Sub("foo") + + assert.Equal(t, "13", v.GetString("id")) + assert.Equal(t, "baz", sub.GetString("bar")) +} |
