MCPcopy
hub / github.com/appleboy/gin-jwt / TestInMemoryRefreshTokenStore_Get

Function TestInMemoryRefreshTokenStore_Get

store/memory_test.go:72–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestInMemoryRefreshTokenStore_Get(t *testing.T) {
73 store := NewInMemoryRefreshTokenStore()
74 user := &User{ID: "123", Username: "testuser", Email: "test@example.com"}
75 expiry := time.Now().Add(time.Hour)
76
77 // Set a token
78 err := store.Set(context.Background(), "token123", user, expiry)
79 if err != nil {
80 t.Fatalf("Set() returned error: %v", err)
81 }
82
83 // Get the token
84 userData, err := store.Get(context.Background(), "token123")
85 if err != nil {
86 t.Fatalf("Get() returned error: %v", err)
87 }
88
89 retrievedUser, ok := userData.(*User)
90 if !ok {
91 t.Fatal("Retrieved user data is not of type *User")
92 }
93
94 if retrievedUser.ID != user.ID || retrievedUser.Username != user.Username ||
95 retrievedUser.Email != user.Email {
96 t.Fatalf("Retrieved user data doesn't match. Expected: %+v, Got: %+v", user, retrievedUser)
97 }
98}
99
100func TestInMemoryRefreshTokenStore_GetNonExistent(t *testing.T) {
101 store := NewInMemoryRefreshTokenStore()

Callers

nothing calls this directly

Calls 3

SetMethod · 0.95
GetMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…