Skip to content

Commit

Permalink
fix: replace os.Setenv with t.Setenv
Browse files Browse the repository at this point in the history
Signed-off-by: isubasinghe <[email protected]>
  • Loading branch information
isubasinghe committed Sep 9, 2024
1 parent 00c3381 commit 8d134b8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions workflow/sync/sync_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sync
import (
"context"
"fmt"
"os"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -885,7 +884,7 @@ func TestMutexMigration(t *testing.T) {
concurrenyMgr.syncLockMap = make(map[string]Semaphore)
wfMutex1 := wfMutex.DeepCopy()
wfMutex1.Name = "test1"
os.Setenv("HOLDER_KEY_VERSION", "v1")
t.Setenv("HOLDER_KEY_VERSION", "v1")
status, _, _, err := concurrenyMgr.TryAcquire(wfMutex1, wfMutex1.Name, wfMutex1.Spec.Synchronization)
require.NoError(err)
assert.True(status)
Expand Down Expand Up @@ -923,7 +922,7 @@ func TestMutexMigration(t *testing.T) {
concurrenyMgr.syncLockMap = make(map[string]Semaphore)
wfMutex2 := wfMutex.DeepCopy()
wfMutex2.Name = "test1"
os.Setenv("HOLDER_KEY_VERSION", "v1")
t.Setenv("HOLDER_KEY_VERSION", "v1")
status, _, _, err := concurrenyMgr.TryAcquire(wfMutex2, wfMutex2.Name, wfMutex2.Spec.Synchronization)
require.NoError(err)
assert.True(status)
Expand All @@ -934,7 +933,7 @@ func TestMutexMigration(t *testing.T) {
holdingName := items[len(items)-1]
assert.Equal(wfMutex2.Status.Synchronization.Mutex.Holding[0].Holder, holdingName)

os.Setenv("HOLDER_KEY_VERSION", "v2")
t.Setenv("HOLDER_KEY_VERSION", "v2")

concurrenyMgr.syncLockMap = make(map[string]Semaphore)
wfs := []wfv1.Workflow{*wfMutex2.DeepCopy()}
Expand All @@ -961,7 +960,7 @@ func TestMutexMigration(t *testing.T) {
}

func TestV2Mutex(t *testing.T) {
os.Setenv("HOLDER_KEY_VERSION", "v2")
t.Setenv("HOLDER_KEY_VERSION", "v2")
assert := assert.New(t)
require := require.New(t)
kube := fake.NewSimpleClientset()
Expand Down

0 comments on commit 8d134b8

Please sign in to comment.