Skip to content

Commit

Permalink
fix: set mocked gin request context manually
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Aug 28, 2023
1 parent bdfdff3 commit eb51458
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/token/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package token

import (
"context"
"net/http"
"net/http/httptest"
"testing"
"time"
Expand Down Expand Up @@ -64,6 +65,8 @@ func TestTokenManager_Refresh(t *testing.T) {
resp := httptest.NewRecorder()
context, _ := gin.CreateTestContext(resp)
context.Set("database", db)
req, _ := http.NewRequestWithContext(context, "", "", nil)
context.Request = req

// run tests
got, err := tm.Refresh(context, rt)
Expand Down Expand Up @@ -123,6 +126,8 @@ func TestTokenManager_Refresh_Expired(t *testing.T) {
resp := httptest.NewRecorder()
context, _ := gin.CreateTestContext(resp)
context.Set("database", db)
req, _ := http.NewRequestWithContext(context, "", "", nil)
context.Request = req

// run tests
_, err = tm.Refresh(context, rt)
Expand Down

0 comments on commit eb51458

Please sign in to comment.