Skip to content

Commit

Permalink
Merge pull request #1393 from mtrmac/Setenv
Browse files Browse the repository at this point in the history
Use testing.T.Setenv
  • Loading branch information
giuseppe committed Oct 18, 2022
2 parents 1a56f20 + 4c96809 commit 684d84e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions types/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ func TestGetRootlessStorageOpts(t *testing.T) {
})

t.Run("STORAGE_DRIVER=btrfs", func(t *testing.T) {
os.Setenv("STORAGE_DRIVER", "btrfs")
defer os.Unsetenv("STORAGE_DRIVER")
t.Setenv("STORAGE_DRIVER", "btrfs")
systemOpts := StoreOptions{}
systemOpts.GraphDriverName = vfsDriver
storageOpts, err := getRootlessStorageOpts(1000, systemOpts)
Expand All @@ -86,8 +85,7 @@ func TestGetRootlessStorageOpts(t *testing.T) {
})

t.Run("STORAGE_DRIVER=zfs", func(t *testing.T) {
os.Setenv("STORAGE_DRIVER", "zfs")
defer os.Unsetenv("STORAGE_DRIVER")
t.Setenv("STORAGE_DRIVER", "zfs")
systemOpts := StoreOptions{}
systemOpts.GraphDriverName = vfsDriver
storageOpts, err := getRootlessStorageOpts(1000, systemOpts)
Expand Down
6 changes: 2 additions & 4 deletions types/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ func TestDefaultStoreOpts(t *testing.T) {
}

func TestStorageConfOverrideEnvironmentDefaultConfigFileRootless(t *testing.T) {
os.Setenv("CONTAINERS_STORAGE_CONF", "default_override_test.conf")
defer os.Unsetenv("CONTAINERS_STORAGE_CONF")
t.Setenv("CONTAINERS_STORAGE_CONF", "default_override_test.conf")
defaultFile, err := DefaultConfigFile(true)

expectedPath := "default_override_test.conf"
Expand All @@ -280,8 +279,7 @@ func TestStorageConfOverrideEnvironmentDefaultConfigFileRootless(t *testing.T) {
}

func TestStorageConfOverrideEnvironmentDefaultConfigFileRoot(t *testing.T) {
os.Setenv("CONTAINERS_STORAGE_CONF", "default_override_test.conf")
defer os.Unsetenv("CONTAINERS_STORAGE_CONF")
t.Setenv("CONTAINERS_STORAGE_CONF", "default_override_test.conf")
defaultFile, err := DefaultConfigFile(false)

expectedPath := "default_override_test.conf"
Expand Down

0 comments on commit 684d84e

Please sign in to comment.