blob: 6e47d469ea6dc25227efccfa9208e2dff3dfa582 (
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
25
26
27
28
29
30
31
32
33
|
package funcs
import (
"context"
"os"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreateEnvFuncs(t *testing.T) {
for i := 0; i < 10; i++ {
// Run this a bunch to catch race conditions
t.Run(strconv.Itoa(i), func(t *testing.T) {
t.Parallel()
ctx := context.Background()
fmap := CreateEnvFuncs(ctx)
actual := fmap["env"].(func() interface{})
assert.Same(t, ctx, actual().(*EnvFuncs).ctx)
})
}
}
func TestEnvGetenv(t *testing.T) {
ef := &EnvFuncs{}
expected := os.Getenv("USER")
assert.Equal(t, expected, ef.Getenv("USER"))
assert.Equal(t, "foo", ef.Getenv("bogusenvvar", "foo"))
}
|