On GitHub Enterprise, the documentation URL for abuse limit errors
is not the same as for the public GitHub API.
The documentation URL in abuse limit errors on public GitHub API is:
"https://developer.github.com/v3/#abuse-rate-limits"
GitHub Enterprise instances will return a version-specific URL, such as:
"https://developer.github.com/enterprise/2.12/v3/#abuse-rate-limits"
This changes the error type check to detect AbuseRateLimitError error
in a GitHub-version-agnostic way.
Use testMethod to test the request method instead of manually comparing
it and testing. This change is to make things consistent through out the
code base.
Fixes#829.
This refactor removes the global test variables used by all tests,
replacing them with local variables that are independent in each test.
This is better style, easier to read and be confident about correctness,
and allows tests to be parallelized in the future.
Resolves#762.
This is a convenience helper for creating an enterprise client with
custom URLs. Previous code that uses NewClient and sets its
BaseURL, UploadURL fields is still valid. This method is for convenice
and better discoverability within godoc. It also aligns with a similar
method in githubql package (for GitHub API v4).
Resolves#756.
The goal of this change is to catch bugs where endpoint uses an
absolute URL rather than relative. The difference in behavior only
occurs when a non-empty BaseURL path is used. So we do that.
We do it in a way that doesn't require rewriting a lot of tests or
shifting the responsibility of catching this mistake to writing the
test correctly. Instead, it's a global automated check.
With this change, a test for an endpoint would now fail if that method
incorrectly uses an absolute URL. For example:
$ go test
FAIL: Client.BaseURL path prefix is not preserved in the request URL:
/users?page=2&since=1
Did you accidentally use an absolute endpoint URL rather than relative?
See https://github.com/google/go-github/issues/752 for information.
--- FAIL: TestUsersService_ListAll (0.00s)
users_test.go:166: Users.Get returned error: GET http://127.0.0.1:59907/users?page=2&since=1: 500 []
users_test.go:171: Users.ListAll returned [], want [github.User{ID:2}]
FAIL
exit status 1
FAIL github.com/google/go-github/github 0.250s
Fixes#752.
Closes#753.
This does not change behavior, since these relative URLs are equivalent
to the previous absolute URLs. Tests continue to pass.
However, once #752 is resolved, absolute URLs will no longer work in
tests. So we need to change all absolute URLs to relative to keep tests
passing.
Helps #752.