(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…