@@ -111,12 +111,13 @@ func TestWithPATScopes(t *testing.T) {
111111
112112 for _ , tt := range tests {
113113 t .Run (tt .name , func (t * testing.T ) {
114- var capturedTokenInfo * ghcontext.TokenInfo
114+ var capturedScopes []string
115+ var scopesFound bool
115116 var nextHandlerCalled bool
116117
117118 nextHandler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
118119 nextHandlerCalled = true
119- capturedTokenInfo , _ = ghcontext .GetTokenInfo (r .Context ())
120+ capturedScopes , scopesFound = ghcontext .GetTokenScopes (r .Context ())
120121 w .WriteHeader (http .StatusOK )
121122 })
122123
@@ -141,10 +142,9 @@ func TestWithPATScopes(t *testing.T) {
141142
142143 assert .Equal (t , tt .expectNextHandlerCalled , nextHandlerCalled , "next handler called mismatch" )
143144
144- if tt .expectNextHandlerCalled && tt .tokenInfo != nil {
145- require .NotNil (t , capturedTokenInfo , "expected token info in context" )
146- assert .Equal (t , tt .expectScopesFetched , capturedTokenInfo .ScopesFetched )
147- assert .Equal (t , tt .expectedScopes , capturedTokenInfo .Scopes )
145+ if tt .expectNextHandlerCalled {
146+ assert .Equal (t , tt .expectScopesFetched , scopesFound , "scopes found mismatch" )
147+ assert .Equal (t , tt .expectedScopes , capturedScopes )
148148 }
149149 })
150150 }
@@ -154,9 +154,12 @@ func TestWithPATScopes_PreservesExistingTokenInfo(t *testing.T) {
154154 logger := slog .Default ()
155155
156156 var capturedTokenInfo * ghcontext.TokenInfo
157+ var capturedScopes []string
158+ var scopesFound bool
157159
158160 nextHandler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
159161 capturedTokenInfo , _ = ghcontext .GetTokenInfo (r .Context ())
162+ capturedScopes , scopesFound = ghcontext .GetTokenScopes (r .Context ())
160163 w .WriteHeader (http .StatusOK )
161164 })
162165
@@ -182,6 +185,6 @@ func TestWithPATScopes_PreservesExistingTokenInfo(t *testing.T) {
182185 require .NotNil (t , capturedTokenInfo )
183186 assert .Equal (t , originalTokenInfo .Token , capturedTokenInfo .Token )
184187 assert .Equal (t , originalTokenInfo .TokenType , capturedTokenInfo .TokenType )
185- assert .True (t , capturedTokenInfo . ScopesFetched )
186- assert .Equal (t , []string {"repo" , "user" }, capturedTokenInfo . Scopes )
188+ assert .True (t , scopesFound )
189+ assert .Equal (t , []string {"repo" , "user" }, capturedScopes )
187190}
0 commit comments