forked from testcontainers/testcontainers-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
44 lines (34 loc) · 950 Bytes
/
config_test.go
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
38
39
40
41
42
43
44
package testcontainers
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/testcontainers/testcontainers-go/internal/config"
)
// unset environment variables to avoid side effects
// execute this function before each test
func resetTestEnv(t *testing.T) {
t.Setenv("TESTCONTAINERS_RYUK_DISABLED", "")
t.Setenv("TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED", "")
}
func TestReadConfig(t *testing.T) {
resetTestEnv(t)
t.Cleanup(func() {
config.Reset()
})
t.Run("Config is read just once", func(t *testing.T) {
t.Setenv("HOME", "")
t.Setenv("USERPROFILE", "") // Windows support
t.Setenv("TESTCONTAINERS_RYUK_DISABLED", "true")
cfg := ReadConfig()
expected := TestcontainersConfig{
RyukDisabled: true,
Config: config.Config{
RyukDisabled: true,
},
}
assert.Equal(t, expected, cfg)
t.Setenv("TESTCONTAINERS_RYUK_DISABLED", "false")
cfg = ReadConfig()
assert.Equal(t, expected, cfg)
})
}