From b9382cfc5d778b7ea87dbb97f34df250feeb4e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Durgun?= Date: Thu, 20 Apr 2023 16:19:09 +0300 Subject: [PATCH] chore(ci): Fix data race in store test (#1537) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(ci): Fix data race in store test Signed-off-by: Oğuzhan Durgun * Use package-level functions Signed-off-by: Oğuzhan Durgun --------- Signed-off-by: Oğuzhan Durgun --- internal/storage/git/store_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/storage/git/store_test.go b/internal/storage/git/store_test.go index c983de5d5..957caba62 100644 --- a/internal/storage/git/store_test.go +++ b/internal/storage/git/store_test.go @@ -146,7 +146,6 @@ func TestUpdateStore(t *testing.T) { } numPolicySets := 10 - rng := rand.New(rand.NewSource(time.Now().Unix())) //nolint:gosec t.Run("no changes", func(t *testing.T) { param := setupUpdateStoreTest(t, numPolicySets) @@ -170,7 +169,7 @@ func TestUpdateStore(t *testing.T) { }, nil) checkEvents := storage.TestSubscription(param.store) - pset := genPolicySet(rng.Intn(numPolicySets)) + pset := genPolicySet(rand.Intn(numPolicySets)) //nolint:gosec require.NoError(t, commitToGitRepo(param.sourceGitDir, "Modify policy", func(_ *git.Worktree) error { for _, p := range pset { @@ -205,7 +204,7 @@ func TestUpdateStore(t *testing.T) { }, nil) checkEvents := storage.TestSubscription(param.store) - pset := genPolicySet(rng.Intn(numPolicySets)) + pset := genPolicySet(rand.Intn(numPolicySets)) //nolint:gosec wantEvents := make([]storage.Event, len(pset)) psetEventIdx := make(map[string]int, len(pset)) @@ -314,7 +313,7 @@ func TestUpdateStore(t *testing.T) { }, nil) checkEvents := storage.TestSubscription(param.store) - pset := genPolicySet(rng.Intn(numPolicySets)) + pset := genPolicySet(rand.Intn(numPolicySets)) //nolint:gosec require.NoError(t, commitToGitRepo(param.sourceGitDir, "Delete policy", func(wt *git.Worktree) error { for file := range pset { @@ -365,7 +364,7 @@ func TestUpdateStore(t *testing.T) { }, nil) checkEvents := storage.TestSubscription(param.store) - pset := genPolicySet(rng.Intn(numPolicySets)) + pset := genPolicySet(rand.Intn(numPolicySets)) //nolint:gosec require.NoError(t, commitToGitRepo(param.sourceGitDir, "Rename policy", func(wt *git.Worktree) error { for file := range pset { @@ -411,7 +410,7 @@ func TestUpdateStore(t *testing.T) { }, nil) checkEvents := storage.TestSubscription(param.store) - pset := genPolicySet(rng.Intn(numPolicySets)) + pset := genPolicySet(rand.Intn(numPolicySets)) //nolint:gosec require.NoError(t, commitToGitRepo(param.sourceGitDir, "Move policy out", func(wt *git.Worktree) error { for file := range pset {