Skip to content

Commit 9b457f3

Browse files
committed
Add test for EnvVars
1 parent 52f4166 commit 9b457f3

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

value_source_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import (
1212

1313
func TestEnvVarValueSource(t *testing.T) {
1414
t.Run("implements ValueSource", func(t *testing.T) {
15-
src := &envVarValueSource{Key: "foo"}
15+
src := EnvVar("foo")
1616
require.Implements(t, (*ValueSource)(nil), src)
1717

1818
t.Run("not found", func(t *testing.T) {
1919
t.Setenv("foo", "bar")
2020

21-
src := &envVarValueSource{Key: "foo_1"}
21+
src := EnvVar("foo_1")
2222
_, ok := src.Lookup()
2323
require.False(t, ok)
2424
})
@@ -27,7 +27,7 @@ func TestEnvVarValueSource(t *testing.T) {
2727
t.Setenv("foo", "bar")
2828

2929
r := require.New(t)
30-
src := &envVarValueSource{Key: "foo"}
30+
src := EnvVar("foo")
3131

3232
str, ok := src.Lookup()
3333
r.True(ok)
@@ -37,15 +37,15 @@ func TestEnvVarValueSource(t *testing.T) {
3737
})
3838

3939
t.Run("implements fmt.Stringer", func(t *testing.T) {
40-
src := &envVarValueSource{Key: "foo"}
40+
src := EnvVar("foo")
4141
r := require.New(t)
4242

4343
r.Implements((*fmt.Stringer)(nil), src)
4444
r.Equal("environment variable \"foo\"", src.String())
4545
})
4646

4747
t.Run("implements fmt.GoStringer", func(t *testing.T) {
48-
src := &envVarValueSource{Key: "foo"}
48+
src := EnvVar("foo")
4949
r := require.New(t)
5050

5151
r.Implements((*fmt.GoStringer)(nil), src)
@@ -122,6 +122,16 @@ func TestFilePaths(t *testing.T) {
122122
r.Contains(src.String(), fmt.Sprintf("%[1]q", fileName))
123123
}
124124

125+
func TestValueSourceChainEnvKeys(t *testing.T) {
126+
chain := NewValueSourceChain(
127+
&staticValueSource{"hello"},
128+
)
129+
chain.Append(EnvVars("foo", "bar"))
130+
131+
r := require.New(t)
132+
r.Equal([]string{"foo", "bar"}, chain.EnvKeys())
133+
}
134+
125135
func TestValueSourceChain(t *testing.T) {
126136
t.Run("implements ValueSource", func(t *testing.T) {
127137
vsc := &ValueSourceChain{}

0 commit comments

Comments
 (0)