Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ListServiceHooks #2917

Merged
merged 1 commit into from Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions github/github-stringify_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions github/misc.go
Expand Up @@ -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
}
69 changes: 0 additions & 69 deletions github/misc_test.go
Expand Up @@ -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{}, "{}")

Expand Down Expand Up @@ -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)
}
11 changes: 0 additions & 11 deletions test/integration/misc_test.go
Expand Up @@ -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")
}
}