Skip to content

Commit

Permalink
chore(ci): Fix data race in store test (#1537)
Browse files Browse the repository at this point in the history
* chore(ci): Fix data race in store test

Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>

* Use package-level functions

Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>

---------

Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>
  • Loading branch information
oguzhand95 committed Apr 20, 2023
1 parent 6af9d52 commit b9382cf
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/storage/git/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b9382cf

Please sign in to comment.