56 Commits
Author SHA1 Message Date
Ajay Kemparaj f9fec07de4 feat: Require Go 1.26 and use new(expr) for pointer literals (#4481) 2026-08-28 12:18:49 -04:00
Manav Sharma 65628e2d60 refactor!: Rename UsersService.Edit to Update, introduce UserUpdateRequest, and pass request by value (#4433)
BREAKING CHANGE: `UsersService.Edit` is now `Update` and uses a new `UserUpdateRequest` body value.
2026-08-06 12:01:43 -04:00
Oleksandr Redko 531d1cfb59 test: Fix test names and error messages (#4284) 2026-06-05 11:02:34 -04:00
Oleksandr Redko 3215e0320e test: Remove redundant Marshal tests (#4266) 2026-06-04 09:22:07 -04:00
Dhananjay Mishra 0a16e22eba refactor: Use testJSONBody helper for request body assertions in tests (#4183) 2026-05-01 08:13:24 -04:00
Oleksandr Redko ffd18dc823 fix: Add missing User fields (#4146) 2026-04-10 16:19:49 -04:00
Glenn Lewis a2063a76fb chore: Remove unnecessary use of new and &SomeStruct{} and add new extraneousnew custom linter (#4106) 2026-03-18 17:12:53 -04:00
Oleksandr Redko 5158bb8e5f chore: Improve testJSONMarshal (#4042) 2026-02-27 07:27:18 -05:00
Glenn Lewis 71958fb26f fix!: Pass url struct tags by value instead of by reference (#3991)
BREAKING CHANGE: Many `*Options` structs now pass `omitempty` URL struct fields by value instead of by reference.
2026-02-11 14:07:37 -05:00
Dhananjay Mishra b02895efc8 fix!: Replace UserListOptions.ListOptions with UserListOptions.PerPage (#3977)
BREAKING CHANGE: Replaces `UserListOptions.ListOptions` with `UserListOptions.PerPage` which also removes `UsersService.ListAllIter`.
2026-02-08 10:58:31 -05:00
Dhananjay Mishra d1dd1a50d8 chore: Use example.com instead of random URLs in tests (#3948) 2026-02-01 11:59:26 -05:00
Oleksandr Redko 233fe03e17 test: Use t.Context() instead of context.Background() (#3750) 2025-10-03 08:09:47 -04:00
Oleksandr Redko ff1666c906 refactor: Fix revive.unnecessary-format lint issues (#3629) 2025-07-19 14:01:40 -04:00
Oleksandr Redko f66ed85955 feat: Deprecate and replace Bool,Int,Int64,String with Ptr using generics (#3355) 2024-12-10 21:36:09 -05:00
Glenn Lewis dc884c26ca Add t.Parallel to unit tests (#3297) 2024-10-05 07:29:05 -04:00
Glenn Lewis e56d378b96 refactor: Do not call teardown manually in tests (#3296) 2024-10-01 11:52:30 -04:00
WillAbides fd33b81221 Fix linting (#2903) 2023-09-08 08:55:37 -04:00
Glenn Lewis 7b27977c44 Change PrivateRepos from int to int64 (#2738)
Fixes: #2736.
2023-04-05 13:10:17 -04:00
vaibhavgholap23 5d388bdc78 Add test case for JSON resource marshaling (#2548) 2022-10-31 15:24:24 -04:00
Harikesh00 2e86465039 Add test case for JSON resource marshaling (#2521) 2022-10-25 14:34:34 -04:00
sushmita wable cbba2b04f8 Add test cases for JSON resource marshaling (#2189) 2021-10-31 22:34:02 -04:00
Santosh Kavhar 878578e5c9 Add test cases for JSON resource marshaling (#2168) 2021-10-29 12:41:46 -04:00
alihasan070707 c9beee0ff5 Add test cases for JSON resource marshaling (#2149) 2021-10-27 11:43:29 -04:00
Glenn Lewis 34be973ec2 Make test names consistent (#2002) 2021-07-16 07:08:20 -04:00
Sagar Sonwane 51e7595f87 fix: Updated comparisons in test files (#1875)
Replaced all reflect.DeepEqual comparisons in test files with cmp.Equal.

Fixes: #1851
2021-05-26 11:49:24 -07:00
Glenn Lewis 9dd2ad79b6 Improve users.go coverage (#1696) 2020-12-25 19:45:17 -05:00
Glenn Lewis 460db534b8 Refactor context.Background in tests (#1672) 2020-12-16 05:58:28 -05:00
Ryan Mast 2c8de65144 Add missing fields to user and org types (#1548) 2020-05-31 16:04:47 -04:00
Vaibhav Singh 40fcc261cf Remove custom preview headers from "graduated" APIs (#1355)
Fixes #1351.
2019-12-26 10:09:21 -05:00
Kautilya Tripathi 8c4c7c1da9 GitHub Repository Invitation API: Remove custom media type (#1068)
Fixes #708.
2018-12-12 20:20:17 -05:00
Glenn Lewis 5d3c7cb89d Support Preview Hovercard API (#973)
Fixes #875.
Closes #890.
2018-08-10 13:09:23 -04:00
Kshitij Saraogi e48060a28f Migrate IDs to int64 type (#816)
A helper function "Int64" is also implemented to assist the migration of
unit tests.

Refer #597.
2018-01-25 10:59:44 -08:00
Chris King df88dd9538 Remove global test variables in favor of local. (#766)
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.
2017-12-02 14:34:41 -05:00
Sebastian Mæland Pedersen 4c4aea2b66 Add OrganizationService.GetByID method. (#662)
Note: OrganizationService.GetByID uses the undocumented GitHub API
endpoint /organizations/:id.

Change all GetByID tests to fail early with t.Fatalf when error is returned.

Updates #329.
Follows #332 and #333.
2017-07-01 02:19:50 -04:00
Sam Minnée fc60e1f520 Add *ListOptions parameter to 7 methods that support pagination. (#635)
This is an unavoidable breaking API change. To update to new version
without changing behavior, you can provide nil value for *ListOptions.

Bump libraryVersion to 7.

This adds a *ListOptions parameter to 7 methods that support pagination,
but inadvertently omitted this parameter:

-	AuthorizationsService.ListGrants
-	GistsService.ListCommits
-	PullRequestsService.ListReviewers
-	PullRequestsService.ListReviews
-	PullRequestsService.ListReviewComments
-	RepositoriesService.ListPagesBuilds
-	UsersService.ListInvitations

This is needed to support pagination. Without this parameter, it’s not
possible to fetch anything other than the first page (of default size)
of results.

Add _withOptions tests for each of the methods, that ignore the result
but ensure that ?page=2 is added to the API requests.
2017-05-11 21:42:59 -04:00
Dmitri Shuralyov 23d6cb9cac Add support for context package to all endpoints. (#529)
This is a large breaking API change. It is unavoidable and necessary
to resolve #526. This breaking change is part of bump to libraryVersion 3.

It adds ctx context.Context as first parameter to all endpoint methods,
including Do.

Updating for this API change should be easy and the compiler will help
catch instances that need to be updated. For example:

	main.go:193: not enough arguments in call to gh.Activity.MarkRepositoryNotificationsRead
		have (string, string, time.Time)
		want (context.Context, string, string, time.Time)
	...

You should pass the available context as first parameter. If your code
does not have context.Context available and you want to maintain previous
normal behavior, use context.Background(). Don't pass nil context; use
context.TODO() instead if you wish to delay figuring out the best context
to use. Then you can address the TODO at a later time.

Refer to documentation of package context at https://godoc.org/context
for more information.

This commit also changes ./tests/fields to use context.Background()
instead of deprecated oauth2.NoContext.

Resolves #526.
2017-02-20 16:05:42 -05:00
Glenn Lewis 5c1b3a05b4 add support for new repository invitations
Fixes #371.

Change-Id: I97f2fc28ce048442ee8af3bd11c48b5b2084e09b
2016-06-19 21:24:55 -07:00
Glenn Lewis 4ea1b10b74 replace []Issue with []*Issue and for other large structs as well
Note that this is an API-breaking change but should have minimal
impact on users of this package due to the nice inference
properties of the Go programming language.

Bumped `libraryVersion` to `2` due to API-breaking change as
discussed in #376.

Fixes #180.

Change-Id: Ib386135e6b8f306d1f54278968c576f3ceccc4e7
2016-06-19 19:42:35 -07:00
Bryan Boreham c2beba44cf Add missing ListOptions to various structs
Make it possible for callers of IssuesService.ListMilestones() and
similar to step through pages of results.
2016-06-08 10:10:06 -07:00
Quinn Slack 1acbd99794 Add UsersService.GetByID method.
Note: GetByID uses the undocumented GitHub API endpoint /user/:id.

Resolves #329 (assuming #332 is also merged).
Closes #333
2016-04-09 11:37:19 -07:00
griffin_stewie 6387a9448d Add "SuspendedAt" field to User struct. 2016-02-03 17:10:20 -08:00
Will Norris 80ed3576c9 add missing fields for various types
Includes additions to User, Organization, Repository, and Gist.  Some
minor changes to existing fields based on changes in the v3 API (for
example, Gist.User became Gist.Owner).  Most everything else is new
additions.

refs #103
2014-04-23 09:03:36 -07:00
Will Norris 5f1c20afed start of tests for json marshalling of resources
ktoso kind of shamed me with his extensive resource tests in #49 :), so
I'm finally starting to setup a structure for more general testing of
this type.  This change adds the `testJSONMarshal` helper function, and
adds tests for the `User` type.  This includes two checks:

 - check that an empty resource produces an empty JSON object.  This
   effectively verifies that all fields include 'omitempty' so that
   we're not unintentionally sending additional data over the wire.

 - check that a full resource with every field populated produces the
   expected JSON.  This verifies that the JSON field mappings are
   correct.  In this case, it might be okay to use resource samples from
   the GitHub docs, though I do still prefer very simple field values
   since it makes tests easier to read.

When these tests are added for each resource type, we can reduce all of
our other tests to return bare minimal response bodies, since the
resource fields are already being tested at that point.
2013-09-05 09:29:16 -07:00
Will Norris 3072d069f2 switch singular GitHub struct fields to pointers
Like a51d6b4303, this change makes me sad, mainly because it is a
breaking change for all clients, and makes common tasks like reading
data out of structs slightly more work, with no direct benefit. Notably,
developers will need to make sure and check for nil values before trying
to dereference these pointers.  Sadly, the change is still necessary, as
is more fully explained in issue #19.  We can make the nil pointer
checks a little easier by adding some Get* funcs like goprotobuf does.

I spent a lot of time over the last few weeks exploring this change
(switching fields to pointers) versus the much larger change of using
protocol buffers for all GitHub data types.  While the goprotobuf
library is very mature and feature-rich (it's used heavily inside of
Google), it's the wrong tool for this task, since we're not actually
using the proto wire format.  While it does address the immediate
concern in #19, it makes way too many other things terribly awkward.

One of the biggest drawbacks of this change is that it will make the
string output from fmt.Printf("%v") next to useless, since all pointer
values are displayed as their memory address.  To handle that, I'll be
writing a custom String() function for these structs that is heavily
inspired by goprotobuf and internals from go's fmt package.
2013-08-20 13:21:47 -07:00
Will Norris db5ea50996 remove unnecessary type declarations
when initializing a slice of concrete structs, it's not necessary to
declare the type of each item in the slice, since the compiler knows
what you mean.
2013-08-19 11:09:02 -07:00
Will Norris a51d6b4303 return Response object from all API functions
The truth is, this change makes me sad.  It's a breaking change
for all clients and it adds more complexity to the library surface.  In
most cases, clients will simply drop the Response object on the floor
(which is actually all the library itself was doing before this
change... now we're just pushing that off to the client).

Initially, the Response object will be primarily of interest for
functions that return paginated result sets, since the Response.NextPage
field is the only way to know for sure if there are more pages that
should be fetched.  And this is really the cleanest way to get at that
data, so in that respect this change isn't so bad.

It's also worth noting that returning the raw Response object makes a
lot more since in a GitHub library than it may in others, given how
GitHub makes liberal (read: proper) use of HTTP request and response
headers.  Other APIs, like Google's various APIs for example, tend to
push things like pagination links into the response body.  While this is
certainly less of a purist view in terms of REST, it does make the lives
of client developers a lot easier, since then the response body contains
everything you need to know.  But whatever; this is how GitHub rolls, so
we'll roll right along with them.  (Somewhat ironically we are ignoring
the RESTful links in the GitHub response bodies, since we're actually
calling the API in an RPC style and don't do anything with those links.)

We still don't have an easy way to set arbitrary request headers, but
that's a problem for another day.

Fixes #22
2013-08-01 14:31:55 -07:00
Billy Lynch 7767fa6db7 Restructured Users Service files. 2013-08-01 11:53:36 -04:00
Will Norris 82cbe9ba19 Update boilerplate to reflect shared copyright
Since the library has received external contributions, Google is no
longer the sole copyright holder.  Update the boilerplate at the top of
each file to reflect that, and add AUTHORS and CONTRIBUTORS files to
track this information.
2013-06-27 10:08:41 -07:00
Will Norris af26438124 pass and return user emails as slices
there's no real need to use pointers here
2013-06-26 20:16:18 -07:00
Akeda Bagus 9f96faa2c2 Add ListEmails, AddEmails, and DeleteEmails for Users service.
This includes tests for relevant methods. Fixes #14.
2013-06-27 05:49:57 +07:00