Skip to content

Commit d3cf18d

Browse files
Use atomic operations for thread-safe test counter
Co-authored-by: SamMorrowDrums <[email protected]>
1 parent 7e0380c commit d3cf18d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/github/issues_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"net/http"
1010
"strings"
11+
"sync/atomic"
1112
"testing"
1213
"time"
1314

@@ -3044,11 +3045,10 @@ func Test_AddSubIssue_RetryLogic(t *testing.T) {
30443045
name: "successful retry after priority conflict",
30453046
mockedClient: func() *http.Client {
30463047
// Create a handler that fails twice with priority conflict, then succeeds
3047-
var callCount int32
3048+
var callCount atomic.Int32
30483049
handler := func(w http.ResponseWriter, _ *http.Request) {
3049-
count := callCount
3050-
callCount++
3051-
if count < 2 {
3050+
count := callCount.Add(1)
3051+
if count <= 2 {
30523052
// First two calls fail with priority conflict
30533053
w.WriteHeader(http.StatusUnprocessableEntity)
30543054
_, _ = w.Write([]byte(`{"message": "An error occurred while adding the sub-issue to the parent issue. Priority has already been taken"}`))

0 commit comments

Comments
 (0)