Skip to content

Remove deprecated identifiers. #555

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

Merged
merged 1 commit into from
Feb 18, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions github/activity_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func (e *Event) Payload() (payload interface{}) {
payload = &IntegrationInstallationEvent{}
case "IntegrationInstallationRepositoriesEvent":
payload = &IntegrationInstallationRepositoriesEvent{}
case "IssueActivityEvent":
payload = &IssueActivityEvent{}
case "IssueCommentEvent":
payload = &IssueCommentEvent{}
case "IssuesEvent":
Expand Down
13 changes: 0 additions & 13 deletions github/event_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,6 @@ type GollumEvent struct {
Installation *Installation `json:"installation,omitempty"`
}

// IssueActivityEvent represents the payload delivered by Issue webhook.
//
// Deprecated: Use IssuesEvent instead.
type IssueActivityEvent struct {
Action *string `json:"action,omitempty"`
Issue *Issue `json:"issue,omitempty"`

// The following fields are only populated by Webhook events.
Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}

// EditChange represents the changes when an issue, pull request, or comment has
// been edited.
type EditChange struct {
Expand Down
32 changes: 0 additions & 32 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ import (
"github.com/google/go-querystring/query"
)

const (
// StatusUnprocessableEntity is the status code returned when sending a request with invalid fields.
StatusUnprocessableEntity = 422
)

const (
libraryVersion = "3"
defaultBaseURL = "https://github.com/api/"
Expand Down Expand Up @@ -383,19 +378,6 @@ func parseRate(r *http.Response) Rate {
return rate
}

// Rate specifies the current rate limit for the client as determined by the
// most recent API call. If the client is used in a multi-user application,
// this rate may not always be up-to-date.
//
// Deprecated: Use the Response.Rate returned from most recent API call instead.
// Call RateLimits() to check the current rate.
func (c *Client) Rate() Rate {
c.rateMu.Lock()
rate := c.rateLimits[c.mostRecent]
c.rateMu.Unlock()
return rate
}

// Do sends an API request and returns the API response. The API response is
// JSON decoded and stored in the value pointed to by v, or returned as an
// error if an API error has occurred. If v implements the io.Writer
Expand Down Expand Up @@ -730,20 +712,6 @@ func category(path string) rateLimitCategory {
}
}

// RateLimit returns the core rate limit for the current client.
//
// Deprecated: RateLimit is deprecated, use RateLimits instead.
func (c *Client) RateLimit() (*Rate, *Response, error) {
limits, resp, err := c.RateLimits()
if err != nil {
return nil, resp, err
}
if limits == nil {
return nil, resp, errors.New("RateLimits returned nil limits and error; unable to extract Core rate limit")
}
return limits.Core, resp, nil
}

// RateLimits returns the rate limits for the current client.
func (c *Client) RateLimits() (*RateLimits, *Response, error) {
req, err := c.NewRequest("GET", "rate_limit", nil)
Expand Down
60 changes: 10 additions & 50 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,30 +407,20 @@ func TestDo_rateLimit(t *testing.T) {
w.Header().Add(headerRateReset, "1372700873")
})

if got, want := client.Rate().Limit, 0; got != want {
t.Errorf("Client rate limit = %v, want %v", got, want)
}
if got, want := client.Rate().Remaining, 0; got != want {
t.Errorf("Client rate remaining = %v, got %v", got, want)
}
if !client.Rate().Reset.IsZero() {
t.Errorf("Client rate reset not initialized to zero value")
}

req, _ := client.NewRequest("GET", "/", nil)
_, err := client.Do(req, nil)
resp, err := client.Do(req, nil)
if err != nil {
t.Errorf("Do returned unexpected error: %v", err)
}
if got, want := client.Rate().Limit, 60; got != want {
if got, want := resp.Rate.Limit, 60; got != want {
t.Errorf("Client rate limit = %v, want %v", got, want)
}
if got, want := client.Rate().Remaining, 59; got != want {
if got, want := resp.Rate.Remaining, 59; got != want {
t.Errorf("Client rate remaining = %v, want %v", got, want)
}
reset := time.Date(2013, 7, 1, 17, 47, 53, 0, time.UTC)
if client.Rate().Reset.UTC() != reset {
t.Errorf("Client rate reset = %v, want %v", client.Rate().Reset, reset)
if resp.Rate.Reset.UTC() != reset {
t.Errorf("Client rate reset = %v, want %v", resp.Rate.Reset, reset)
}
}

Expand All @@ -447,23 +437,22 @@ func TestDo_rateLimit_errorResponse(t *testing.T) {
})

req, _ := client.NewRequest("GET", "/", nil)
_, err := client.Do(req, nil)

resp, err := client.Do(req, nil)
if err == nil {
t.Error("Expected error to be returned.")
}
if _, ok := err.(*RateLimitError); ok {
t.Errorf("Did not expect a *RateLimitError error; got %#v.", err)
}
if got, want := client.Rate().Limit, 60; got != want {
if got, want := resp.Rate.Limit, 60; got != want {
t.Errorf("Client rate limit = %v, want %v", got, want)
}
if got, want := client.Rate().Remaining, 59; got != want {
if got, want := resp.Rate.Remaining, 59; got != want {
t.Errorf("Client rate remaining = %v, want %v", got, want)
}
reset := time.Date(2013, 7, 1, 17, 47, 53, 0, time.UTC)
if client.Rate().Reset.UTC() != reset {
t.Errorf("Client rate reset = %v, want %v", client.Rate().Reset, reset)
if resp.Rate.Reset.UTC() != reset {
t.Errorf("Client rate reset = %v, want %v", resp.Rate.Reset, reset)
}
}

Expand Down Expand Up @@ -764,35 +753,6 @@ func TestError_Error(t *testing.T) {
}
}

func TestRateLimit(t *testing.T) {
setup()
defer teardown()

mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) {
if m := "GET"; m != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, m)
}
fmt.Fprint(w, `{"resources":{
"core": {"limit":2,"remaining":1,"reset":1372700873},
"search": {"limit":3,"remaining":2,"reset":1372700874}
}}`)
})

rate, _, err := client.RateLimit()
if err != nil {
t.Errorf("Rate limit returned error: %v", err)
}

want := &Rate{
Limit: 2,
Remaining: 1,
Reset: Timestamp{time.Date(2013, 7, 1, 17, 47, 53, 0, time.UTC).Local()},
}
if !reflect.DeepEqual(rate, want) {
t.Errorf("RateLimit returned %+v, want %+v", rate, want)
}
}

func TestRateLimits(t *testing.T) {
setup()
defer teardown()
Expand Down
8 changes: 4 additions & 4 deletions github/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestZen(t *testing.T) {
}
}

func TestRepositoriesService_ListServiceHooks(t *testing.T) {
func TestListServiceHooks(t *testing.T) {
setup()
defer teardown()

Expand All @@ -153,9 +153,9 @@ func TestRepositoriesService_ListServiceHooks(t *testing.T) {
}]`)
})

hooks, _, err := client.Repositories.ListServiceHooks()
hooks, _, err := client.ListServiceHooks()
if err != nil {
t.Errorf("Repositories.ListHooks returned error: %v", err)
t.Errorf("ListServiceHooks returned error: %v", err)
}

want := []*ServiceHook{{
Expand All @@ -165,6 +165,6 @@ func TestRepositoriesService_ListServiceHooks(t *testing.T) {
Schema: [][]string{{"a", "b"}},
}}
if !reflect.DeepEqual(hooks, want) {
t.Errorf("Repositories.ListServiceHooks returned %+v, want %+v", hooks, want)
t.Errorf("ListServiceHooks returned %+v, want %+v", hooks, want)
}
}
2 changes: 1 addition & 1 deletion github/orgs_teams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) {

mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
w.WriteHeader(StatusUnprocessableEntity)
w.WriteHeader(http.StatusUnprocessableEntity)
})

_, err := client.Organizations.AddTeamRepo(1, "o", "r", nil)
Expand Down
15 changes: 0 additions & 15 deletions github/repos_contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package github
import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -64,20 +63,6 @@ func (r RepositoryContent) String() string {
return Stringify(r)
}

// Decode decodes the file content if it is base64 encoded.
//
// Deprecated: Use GetContent instead.
func (r *RepositoryContent) Decode() ([]byte, error) {
if *r.Encoding != "base64" {
return nil, errors.New("cannot decode non-base64")
}
o, err := base64.StdEncoding.DecodeString(*r.Content)
if err != nil {
return nil, err
}
return o, nil
}

// GetContent returns the content of r, decoding it if necessary.
func (r *RepositoryContent) GetContent() (string, error) {
var encoding string
Expand Down
35 changes: 0 additions & 35 deletions github/repos_contents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,6 @@ import (
"testing"
)

func TestRepositoryContent_Decode(t *testing.T) {
tests := []struct {
encoding, content *string // input encoding and content
want string // desired output
wantErr bool // whether an error is expected
}{
{
encoding: String("base64"),
content: String("aGVsbG8="),
want: "hello",
wantErr: false,
},
{
encoding: String("bad"),
content: String("aGVsbG8="),
want: "",
wantErr: true,
},
}

for _, tt := range tests {
r := RepositoryContent{Encoding: tt.encoding, Content: tt.content}
o, err := r.Decode()
if err != nil && !tt.wantErr {
t.Errorf("RepositoryContent(%q, %q) returned unexpected error: %v", tt.encoding, tt.content, err)
}
if err == nil && tt.wantErr {
t.Errorf("RepositoryContent(%q, %q) did not return unexpected error", tt.encoding, tt.content)
}
if got, want := string(o), tt.want; got != want {
t.Errorf("RepositoryContent.Decode returned %+v, want %+v", got, want)
}
}
}

func TestRepositoryContent_GetContent(t *testing.T) {
tests := []struct {
encoding, content *string // input encoding and content
Expand Down
1 change: 0 additions & 1 deletion github/repos_deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ type DeploymentStatus struct {
// DeploymentStatusRequest represents a deployment request
type DeploymentStatusRequest struct {
State *string `json:"state,omitempty"`
TargetURL *string `json:"target_url,omitempty"` // Deprecated. Use LogURL instead.
LogURL *string `json:"log_url,omitempty"`
Description *string `json:"description,omitempty"`
EnvironmentURL *string `json:"environment_url,omitempty"`
Expand Down
5 changes: 0 additions & 5 deletions github/repos_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,3 @@ func (s *RepositoriesService) TestHook(owner, repo string, id int) (*Response, e
}
return s.client.Do(req, nil)
}

// ListServiceHooks is deprecated. Use Client.ListServiceHooks instead.
func (s *RepositoriesService) ListServiceHooks() ([]*ServiceHook, *Response, error) {
return s.client.ListServiceHooks()
}