Skip to content

Commit

Permalink
🌱 use testing.Setenv instead of os.Setenv (kubernetes-sigs#10919)
Browse files Browse the repository at this point in the history
* use testing.Setenv instead of os.Setenv

Signed-off-by: sivchari <shibuuuu5@gmail.com>

* fix: build failed error

Signed-off-by: sivchari <shibuuuu5@gmail.com>

---------

Signed-off-by: sivchari <shibuuuu5@gmail.com>
  • Loading branch information
sivchari authored Jul 26, 2024
1 parent 2be3eea commit 9e9985d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
8 changes: 1 addition & 7 deletions cmd/clusterctl/client/config/cert_manager_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package config

import (
"os"
"testing"

. "github.com/onsi/gomega"
Expand Down Expand Up @@ -77,13 +76,8 @@ func TestCertManagerGet(t *testing.T) {
g := NewWithT(t)

for k, v := range tt.envVars {
g.Expect(os.Setenv(k, v)).To(Succeed())
t.Setenv(k, v)
}
defer func() {
for k := range tt.envVars {
g.Expect(os.Unsetenv(k)).To(Succeed())
}
}()
p := &certManagerClient{
reader: tt.fields.reader,
}
Expand Down
8 changes: 1 addition & 7 deletions cmd/clusterctl/client/config/providers_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package config

import (
"fmt"
"os"
"sort"
"testing"

Expand Down Expand Up @@ -148,13 +147,8 @@ func Test_providers_List(t *testing.T) {
g := NewWithT(t)

for k, v := range tt.envVars {
g.Expect(os.Setenv(k, v)).To(Succeed())
t.Setenv(k, v)
}
defer func() {
for k := range tt.envVars {
g.Expect(os.Unsetenv(k)).To(Succeed())
}
}()
p := &providersClient{
reader: tt.fields.configGetter,
}
Expand Down
8 changes: 1 addition & 7 deletions cmd/clusterctl/client/repository/overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package repository

import (
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -74,13 +73,8 @@ func TestOverrides(t *testing.T) {
g := NewWithT(t)

for k, v := range tt.envVars {
g.Expect(os.Setenv(k, v)).To(Succeed())
t.Setenv(k, v)
}
defer func() {
for k := range tt.envVars {
g.Expect(os.Unsetenv(k)).To(Succeed())
}
}()
provider := config.NewProvider("myinfra", "", clusterctlv1.InfrastructureProviderType)
override := newOverride(&newOverrideInput{
configVariablesClient: tt.configVarClient,
Expand Down

0 comments on commit 9e9985d

Please sign in to comment.