blob: b34d97690cb7f3ff27621a23395830123dd87de7 (
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
34
35
36
37
|
package funcs
import (
"context"
"os"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreateEnvFuncs(t *testing.T) {
t.Parallel()
for i := range 10 {
// 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() any)
assert.Equal(t, ctx, actual().(*EnvFuncs).ctx)
})
}
}
func TestEnvGetenv(t *testing.T) {
t.Parallel()
ef := &EnvFuncs{}
expected := os.Getenv("USER")
assert.Equal(t, expected, ef.Getenv("USER"))
assert.Equal(t, "foo", ef.Getenv("bogusenvvar", "foo"))
}
|