From c00226deffe00ce4e4831ef3e3e7fd6a5093b01a Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Wed, 8 Nov 2023 09:33:28 +0200 Subject: [PATCH] Instantiate mock client for each test in branch protection remediations test This ensures we're not overwriting `EXPECT` calls in between the parallel tests and thus ensuring we don't have race conditions. --- .../remediate/gh_branch_protect/gh_branch_protect_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/engine/actions/remediate/gh_branch_protect/gh_branch_protect_test.go b/internal/engine/actions/remediate/gh_branch_protect/gh_branch_protect_test.go index ea0bca8836..6db326996a 100644 --- a/internal/engine/actions/remediate/gh_branch_protect/gh_branch_protect_test.go +++ b/internal/engine/actions/remediate/gh_branch_protect/gh_branch_protect_test.go @@ -247,14 +247,14 @@ func TestBranchProtectionRemediate(t *testing.T) { }, } - mockClient := mock_ghclient.NewMockGitHub(ctrl) - for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() + mockClient := mock_ghclient.NewMockGitHub(ctrl) + engine, err := NewGhBranchProtectRemediator(tt.newRemArgs.actionType, tt.newRemArgs.ghp, tt.newRemArgs.pbuild) if tt.wantInitErr { require.Error(t, err, "expected error")