Skip to content

Commit

Permalink
✅ test: fix failing csrf test
Browse files Browse the repository at this point in the history
A test validating that expired tokens fail was hitting a race condition
with garbage collection. Sometimes, an assertion that expects memory
storage GC to have triggered happens too quickly, causing the assertion
to fail. Give the GC a little bit more time to process before asserting.
  • Loading branch information
nickajacks1 committed Nov 19, 2023
1 parent 1e55045 commit 5b39e15
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion middleware/csrf/csrf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func Test_CSRF_ExpiredToken(t *testing.T) {
utils.AssertEqual(t, 200, ctx.Response.StatusCode())

// Wait for the token to expire
time.Sleep(1 * time.Second)
time.Sleep(1250*time.Millisecond)

// Expired CSRF token
ctx.Request.Reset()
Expand Down

0 comments on commit 5b39e15

Please sign in to comment.