forked from testcontainers/testcontainers-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
45 lines (35 loc) · 1.02 KB
/
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
45
package testcontainers_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/testcontainers/testcontainers-go"
"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 := testcontainers.ReadConfig()
expected := testcontainers.TestcontainersConfig{
RyukDisabled: true,
Config: config.Config{
RyukDisabled: true,
},
}
assert.Equal(t, expected, cfg)
t.Setenv("TESTCONTAINERS_RYUK_DISABLED", "false")
cfg = testcontainers.ReadConfig()
assert.Equal(t, expected, cfg)
})
}