From e94283eaf55803a6cec4509be80ac8a204bb3106 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Tue, 5 Sep 2023 12:59:42 -0500 Subject: [PATCH] remove ListServiceHooks --- github/github-accessors.go | 8 ---- github/github-accessors_test.go | 10 ----- github/github-stringify_test.go | 12 ------ github/misc.go | 32 --------------- github/misc_test.go | 69 --------------------------------- test/integration/misc_test.go | 11 ------ 6 files changed, 142 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 560e0892ed..aad7ba58d4 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -21038,14 +21038,6 @@ func (s *SelectedReposList) GetTotalCount() int { return *s.TotalCount } -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (s *ServiceHook) GetName() string { - if s == nil || s.Name == nil { - return "" - } - return *s.Name -} - // GetFrom returns the From field if it's non-nil, zero value otherwise. func (s *SignatureRequirementEnforcementLevelChanges) GetFrom() string { if s == nil || s.From == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 262cdd5a06..6a3ef0a394 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -24486,16 +24486,6 @@ func TestSelectedReposList_GetTotalCount(tt *testing.T) { s.GetTotalCount() } -func TestServiceHook_GetName(tt *testing.T) { - var zeroValue string - s := &ServiceHook{Name: &zeroValue} - s.GetName() - s = &ServiceHook{} - s.GetName() - s = nil - s.GetName() -} - func TestSignatureRequirementEnforcementLevelChanges_GetFrom(tt *testing.T) { var zeroValue string s := &SignatureRequirementEnforcementLevelChanges{From: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 1d2a47bbff..c14412c2ce 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1820,18 +1820,6 @@ func TestSecurityAndAnalysis_String(t *testing.T) { } } -func TestServiceHook_String(t *testing.T) { - v := ServiceHook{ - Name: String(""), - Events: []string{""}, - SupportedEvents: []string{""}, - } - want := `github.ServiceHook{Name:"", Events:[""], SupportedEvents:[""]}` - if got := v.String(); got != want { - t.Errorf("ServiceHook.String = %v, want %v", got, want) - } -} - func TestSourceImportAuthor_String(t *testing.T) { v := SourceImportAuthor{ ID: Int64(0), diff --git a/github/misc.go b/github/misc.go index 8961524157..a01b716fa2 100644 --- a/github/misc.go +++ b/github/misc.go @@ -245,35 +245,3 @@ func (c *Client) Zen(ctx context.Context) (string, *Response, error) { return buf.String(), resp, nil } - -// ServiceHook represents a hook that has configuration settings, a list of -// available events, and default events. -type ServiceHook struct { - Name *string `json:"name,omitempty"` - Events []string `json:"events,omitempty"` - SupportedEvents []string `json:"supported_events,omitempty"` - Schema [][]string `json:"schema,omitempty"` -} - -func (s *ServiceHook) String() string { - return Stringify(s) -} - -// ListServiceHooks lists all of the available service hooks. -// -// GitHub API docs: https://developer.github.com/webhooks/#services -func (c *Client) ListServiceHooks(ctx context.Context) ([]*ServiceHook, *Response, error) { - u := "hooks" - req, err := c.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - var hooks []*ServiceHook - resp, err := c.Do(ctx, req, &hooks) - if err != nil { - return nil, resp, err - } - - return hooks, resp, nil -} diff --git a/github/misc_test.go b/github/misc_test.go index 4e88ec5452..07cd41500c 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -317,48 +317,6 @@ func TestZen(t *testing.T) { }) } -func TestListServiceHooks(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/hooks", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - fmt.Fprint(w, `[{ - "name":"n", - "events":["e"], - "supported_events":["s"], - "schema":[ - ["a", "b"] - ] - }]`) - }) - - ctx := context.Background() - hooks, _, err := client.ListServiceHooks(ctx) - if err != nil { - t.Errorf("ListServiceHooks returned error: %v", err) - } - - want := []*ServiceHook{{ - Name: String("n"), - Events: []string{"e"}, - SupportedEvents: []string{"s"}, - Schema: [][]string{{"a", "b"}}, - }} - if !cmp.Equal(hooks, want) { - t.Errorf("ListServiceHooks returned %+v, want %+v", hooks, want) - } - - const methodName = "ListServiceHooks" - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.ListServiceHooks(ctx) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - func TestMarkdownRequest_Marshal(t *testing.T) { testJSONMarshal(t, &markdownRequest{}, "{}") @@ -396,30 +354,3 @@ func TestCodeOfConduct_Marshal(t *testing.T) { testJSONMarshal(t, a, want) } - -func TestServiceHook_Marshal(t *testing.T) { - testJSONMarshal(t, &ServiceHook{}, "{}") - - a := &ServiceHook{ - Name: String("name"), - Events: []string{"e"}, - SupportedEvents: []string{"se"}, - Schema: [][]string{{"g"}}, - } - want := `{ - "name": "name", - "events": [ - "e" - ], - "supported_events": [ - "se" - ], - "schema": [ - [ - "g" - ] - ] - }` - - testJSONMarshal(t, a, want) -} diff --git a/test/integration/misc_test.go b/test/integration/misc_test.go index 60753ada7d..e0cee29bf0 100644 --- a/test/integration/misc_test.go +++ b/test/integration/misc_test.go @@ -67,14 +67,3 @@ func TestRateLimits(t *testing.T) { t.Errorf("Core.Reset is more than 1 minute in the past; that doesn't seem right.") } } - -func TestListServiceHooks(t *testing.T) { - hooks, _, err := client.ListServiceHooks(context.Background()) - if err != nil { - t.Fatalf("ListServiceHooks returned error: %v", err) - } - - if len(hooks) == 0 { - t.Fatalf("ListServiceHooks returned no hooks") - } -}