aboutsummaryrefslogtreecommitdiff
path: root/weed/util/config_test.go
blob: 659814a4a0287036c901359e8f64a8c87c5a3bbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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"))
}