MCPcopy Create free account
hub / github.com/google/go-github / TestCredentialsService_Revoke

Function TestCredentialsService_Revoke

github/credentials_test.go:14–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestCredentialsService_Revoke(t *testing.T) {
15 t.Parallel()
16 client, mux, _ := setup(t)
17
18 creds := []string{
19 "ghp_1234567890abcdef1234567890abcdef12345678",
20 "ghp_abcdef1234567890abcdef1234567890abcdef12",
21 }
22
23 mux.HandleFunc("/credentials/revoke", func(w http.ResponseWriter, r *http.Request) {
24 testMethod(t, r, "POST")
25 testJSONBody(t, r, &revokeCredentialsRequest{Credentials: creds})
26 w.WriteHeader(http.StatusAccepted)
27 })
28
29 ctx := t.Context()
30 resp, err := client.Credentials.Revoke(ctx, creds)
31 if !errors.As(err, new(*AcceptedError)) {
32 t.Errorf("Credentials.Revoke returned error: %v (want AcceptedError)", err)
33 }
34 if resp == nil {
35 t.Fatal("Credentials.Revoke returned nil response")
36 }
37 if resp.StatusCode != http.StatusAccepted {
38 t.Errorf("Credentials.Revoke returned status %v, want %v", resp.StatusCode, http.StatusAccepted)
39 }
40
41 const methodName = "Revoke"
42 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
43 return client.Credentials.Revoke(ctx, []string{"a"})
44 })
45}

Callers

nothing calls this directly

Calls 5

testMethodFunction · 0.85
testJSONBodyFunction · 0.85
setupFunction · 0.70
RevokeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…