Skip to content

Commit

Permalink
fix: reset config in tests (#1516)
Browse files Browse the repository at this point in the history
* fix: reset config in tests

* fix: another reset
  • Loading branch information
mdelapenya committed Aug 23, 2023
1 parent 864dbb3 commit b914c67
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func resetTestEnv(t *testing.T) {

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", "")
Expand Down
4 changes: 4 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func TestReadConfig(t *testing.T) {
resetTestEnv(t)

t.Run("Config is read just once", func(t *testing.T) {
t.Cleanup(func() {
Reset()
})

t.Setenv("HOME", "")
t.Setenv("USERPROFILE", "") // Windows support
t.Setenv("DOCKER_HOST", "")
Expand Down
5 changes: 5 additions & 0 deletions logconsumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/testcontainers/testcontainers-go/internal/config"
"github.com/testcontainers/testcontainers-go/wait"
)

Expand Down Expand Up @@ -253,6 +254,10 @@ func Test_StartStop(t *testing.T) {
}

func TestContainerLogWithErrClosed(t *testing.T) {
t.Cleanup(func() {
config.Reset()
})

if providerType == ProviderPodman {
t.Skip("Docker-in-Docker does not work with rootless Podman")
}
Expand Down

0 comments on commit b914c67

Please sign in to comment.