Skip to content

Commit

Permalink
Removing testhook, edithook, and pinghook from the code and the test …
Browse files Browse the repository at this point in the history
…file (google#1111)

Fixes google#1109.
  • Loading branch information
joshuabezaleel authored and gmlewis committed Feb 2, 2019
1 parent b11636a commit cf38b2b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 115 deletions.
42 changes: 0 additions & 42 deletions github/repos_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,6 @@ func (s *RepositoriesService) GetHook(ctx context.Context, owner, repo string, i
return h, resp, nil
}

// EditHook updates a specified Hook.
//
// GitHub API docs: https://developer.github.com/v3/repos/hooks/#edit-a-hook
func (s *RepositoriesService) EditHook(ctx context.Context, owner, repo string, id int64, hook *Hook) (*Hook, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id)
req, err := s.client.NewRequest("PATCH", u, hook)
if err != nil {
return nil, nil, err
}
h := new(Hook)
resp, err := s.client.Do(ctx, req, h)
if err != nil {
return nil, resp, err
}

return h, resp, nil
}

// DeleteHook deletes a specified Hook.
//
// GitHub API docs: https://developer.github.com/v3/repos/hooks/#delete-a-hook
Expand All @@ -198,27 +180,3 @@ func (s *RepositoriesService) DeleteHook(ctx context.Context, owner, repo string
}
return s.client.Do(ctx, req, nil)
}

// PingHook triggers a 'ping' event to be sent to the Hook.
//
// GitHub API docs: https://developer.github.com/v3/repos/hooks/#ping-a-hook
func (s *RepositoriesService) PingHook(ctx context.Context, owner, repo string, id int64) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/hooks/%d/pings", owner, repo, id)
req, err := s.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
}
return s.client.Do(ctx, req, nil)
}

// TestHook triggers a test Hook by github.
//
// GitHub API docs: https://developer.github.com/v3/repos/hooks/#test-a-push-hook
func (s *RepositoriesService) TestHook(ctx context.Context, owner, repo string, id int64) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/hooks/%d/tests", owner, repo, id)
req, err := s.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
}
return s.client.Do(ctx, req, nil)
}
73 changes: 0 additions & 73 deletions github/repos_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,43 +103,6 @@ func TestRepositoriesService_GetHook_invalidOwner(t *testing.T) {
testURLParseError(t, err)
}

func TestRepositoriesService_EditHook(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

input := &Hook{}

mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) {
v := new(Hook)
json.NewDecoder(r.Body).Decode(v)

testMethod(t, r, "PATCH")
if !reflect.DeepEqual(v, input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}

fmt.Fprint(w, `{"id":1}`)
})

hook, _, err := client.Repositories.EditHook(context.Background(), "o", "r", 1, input)
if err != nil {
t.Errorf("Repositories.EditHook returned error: %v", err)
}

want := &Hook{ID: Int64(1)}
if !reflect.DeepEqual(hook, want) {
t.Errorf("Repositories.EditHook returned %+v, want %+v", hook, want)
}
}

func TestRepositoriesService_EditHook_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()

_, _, err := client.Repositories.EditHook(context.Background(), "%", "%", 1, nil)
testURLParseError(t, err)
}

func TestRepositoriesService_DeleteHook(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
Expand All @@ -161,39 +124,3 @@ func TestRepositoriesService_DeleteHook_invalidOwner(t *testing.T) {
_, err := client.Repositories.DeleteHook(context.Background(), "%", "%", 1)
testURLParseError(t, err)
}

func TestRepositoriesService_PingHook(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repos/o/r/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
})

_, err := client.Repositories.PingHook(context.Background(), "o", "r", 1)
if err != nil {
t.Errorf("Repositories.PingHook returned error: %v", err)
}
}

func TestRepositoriesService_TestHook(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repos/o/r/hooks/1/tests", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
})

_, err := client.Repositories.TestHook(context.Background(), "o", "r", 1)
if err != nil {
t.Errorf("Repositories.TestHook returned error: %v", err)
}
}

func TestRepositoriesService_TestHook_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()

_, err := client.Repositories.TestHook(context.Background(), "%", "%", 1)
testURLParseError(t, err)
}

0 comments on commit cf38b2b

Please sign in to comment.