MCPcopy Index your code
hub / github.com/github/github-mcp-server / serveCallback

Function serveCallback

internal/oauth/callback_test.go:15–30  ·  view source on GitHub ↗

serveCallback drives the callback handler with the given query string and returns the recorded response and the single reported result.

(t *testing.T, expectedState, query string)

Source from the content-addressed store, hash-verified

13// serveCallback drives the callback handler with the given query string and
14// returns the recorded response and the single reported result.
15func serveCallback(t *testing.T, expectedState, query string) (*httptest.ResponseRecorder, callbackResult) {
16 t.Helper()
17 cs := &callbackServer{results: make(chan callbackResult, 1)}
18 rec := httptest.NewRecorder()
19 req := httptest.NewRequest(http.MethodGet, "/callback?"+query, nil)
20
21 cs.handler(expectedState).ServeHTTP(rec, req)
22
23 select {
24 case res := <-cs.results:
25 return rec, res
26 default:
27 t.Fatal("handler did not report a result")
28 return nil, callbackResult{}
29 }
30}
31
32func TestCallbackHandlerSuccess(t *testing.T) {
33 rec, res := serveCallback(t, "state123", "code=the-code&state=state123")

Calls 2

handlerMethod · 0.95
ServeHTTPMethod · 0.80

Tested by

no test coverage detected