Repository: google/go-github
Pull request #1767 (2020-12-26 15:34:50)

Improve reactions.go coverage

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1767?src=pr&el=h1) Report
> Merging [#1767](https://codecov.io/gh/google/go-github/pull/1767?src=pr&el=desc) (0a317ff) into [master](https://codecov.io/gh/google/go-github/commit/4489191f88a5044c2497dc8e353418e5a54db21a?el=desc) (4489191) will **increase** coverage by `0.03%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1767/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0)](https://codecov.io/gh/google/go-github/pull/1767?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1767      +/-   ##
==========================================
+ Coverage   96.94%   96.97%   +0.03%     
==========================================
  Files          98       98              
  Lines        6373     6373              
==========================================
+ Hits         6178     6180       +2     
+ Misses        109      108       -1     
+ Partials       86       85       -1     
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1767?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/reactions.go](https://codecov.io/gh/google/go-github/pull/1767/diff?src=pr&el=tree#diff-Z2l0aHViL3JlYWN0aW9ucy5nbw==) | `94.25% <100.00%> (+1.14%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1767?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1767?src=pr&el=footer). Last update [4489191...0a317ff](https://codecov.io/gh/google/go-github/pull/1767?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/github/reactions.go b/github/reactions.go
index 676bf6ac..08387cb5 100644
--- a/github/reactions.go
+++ b/github/reactions.go
@@ -434,7 +434,7 @@ func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Contex
 	var m []*Reaction
 	resp, err := s.client.Do(ctx, req, &m)
 	if err != nil {
-		return nil, nil, err
+		return nil, resp, err
 	}
 	return m, resp, nil
 }


Test patch:
diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go
index be010896..ec41b3d7 100644
--- a/github/orgs_members_test.go
+++ b/github/orgs_members_test.go
@@ -292,6 +292,56 @@ func TestOrganizationsService_RemoveMember_invalidOrg(t *testing.T) {
 	testURLParseError(t, err)
 }
 
+func TestOrganizationsService_PublicizeMembership(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "PUT")
+	})
+
+	ctx := context.Background()
+	_, err := client.Organizations.PublicizeMembership(ctx, "o", "u")
+	if err != nil {
+		t.Errorf("Organizations.PublicizeMembership returned error: %v", err)
+	}
+
+	const methodName = "PublicizeMembership"
+	testBadOptions(t, methodName, func() (err error) {
+		_, err = client.Organizations.PublicizeMembership(ctx, "\n", "\n")
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		return client.Organizations.PublicizeMembership(ctx, "o", "u")
+	})
+}
+
+func TestOrganizationsService_ConcealMembership(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "DELETE")
+	})
+
+	ctx := context.Background()
+	_, err := client.Organizations.ConcealMembership(ctx, "o", "u")
+	if err != nil {
+		t.Errorf("Organizations.ConcealMembership returned error: %v", err)
+	}
+
+	const methodName = "ConcealMembership"
+	testBadOptions(t, methodName, func() (err error) {
+		_, err = client.Organizations.ConcealMembership(ctx, "\n", "\n")
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		return client.Organizations.ConcealMembership(ctx, "o", "u")
+	})
+}
+
 func TestOrganizationsService_ListOrgMemberships(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
diff --git a/github/reactions_test.go b/github/reactions_test.go
index 031980c3..5bcad411 100644
--- a/github/reactions_test.go
+++ b/github/reactions_test.go
@@ -89,7 +89,7 @@ func TestReactionsService_ListCommentReactions(t *testing.T) {
 
 	const methodName = "ListCommentReactions"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.ListCommentReactions(ctx, "\n", "\n", 1, opt)
+		_, _, err = client.Reactions.ListCommentReactions(ctx, "\n", "\n", -1, opt)
 		return err
 	})
 
@@ -126,7 +126,7 @@ func TestReactionsService_CreateCommentReaction(t *testing.T) {
 
 	const methodName = "CreateCommentReaction"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.CreateCommentReaction(ctx, "\n", "\n", 1, "+1")
+		_, _, err = client.Reactions.CreateCommentReaction(ctx, "\n", "\n", -1, "\n")
 		return err
 	})
 
@@ -160,10 +160,17 @@ func TestReactionsService_ListIssueReactions(t *testing.T) {
 	if !reflect.DeepEqual(got, want) {
 		t.Errorf("ListIssueReactions = %+v, want %+v", got, want)
 	}
+}
+
+func TestReactionsService_ListIssueReactions_coverage(t *testing.T) {
+	client, _, _, teardown := setup()
+	defer teardown()
+
+	ctx := context.Background()
 
 	const methodName = "ListIssueReactions"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.ListIssueReactions(ctx, "\n", "\n", 1, nil)
+		_, _, err = client.Reactions.ListIssueReactions(ctx, "\n", "\n", -1, &ListOptions{})
 		return err
 	})
 
@@ -200,7 +207,7 @@ func TestReactionsService_CreateIssueReaction(t *testing.T) {
 
 	const methodName = "CreateIssueReaction"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.CreateIssueReaction(ctx, "\n", "\n", 1, "+1")
+		_, _, err = client.Reactions.CreateIssueReaction(ctx, "\n", "\n", -1, "\n")
 		return err
 	})
 
@@ -234,10 +241,17 @@ func TestReactionsService_ListIssueCommentReactions(t *testing.T) {
 	if !reflect.DeepEqual(got, want) {
 		t.Errorf("ListIssueCommentReactions = %+v, want %+v", got, want)
 	}
+}
+
+func TestReactionsService_ListIssueCommentReactions_coverage(t *testing.T) {
+	client, _, _, teardown := setup()
+	defer teardown()
+
+	ctx := context.Background()
 
 	const methodName = "ListIssueCommentReactions"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.ListIssueCommentReactions(ctx, "\n", "\n", 1, nil)
+		_, _, err = client.Reactions.ListIssueCommentReactions(ctx, "\n", "\n", -1, &ListOptions{})
 		return err
 	})
 
@@ -274,7 +288,7 @@ func TestReactionsService_CreateIssueCommentReaction(t *testing.T) {
 
 	const methodName = "CreateIssueCommentReaction"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.CreateIssueCommentReaction(ctx, "\n", "\n", 1, "+1")
+		_, _, err = client.Reactions.CreateIssueCommentReaction(ctx, "\n", "\n", -1, "\n")
 		return err
 	})
 
@@ -308,10 +322,17 @@ func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) {
 	if !reflect.DeepEqual(got, want) {
 		t.Errorf("ListPullRequestCommentReactions = %+v, want %+v", got, want)
 	}
+}
+
+func TestReactionsService_ListPullRequestCommentReactions_coverage(t *testing.T) {
+	client, _, _, teardown := setup()
+	defer teardown()
+
+	ctx := context.Background()
 
 	const methodName = "ListPullRequestCommentReactions"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.ListPullRequestCommentReactions(ctx, "\n", "\n", 1, nil)
+		_, _, err = client.Reactions.ListPullRequestCommentReactions(ctx, "\n", "\n", -1, &ListOptions{})
 		return err
 	})
 
@@ -348,7 +369,7 @@ func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) {
 
 	const methodName = "CreatePullRequestCommentReaction"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.CreatePullRequestCommentReaction(ctx, "\n", "\n", 1, "+1")
+		_, _, err = client.Reactions.CreatePullRequestCommentReaction(ctx, "\n", "\n", -1, "\n")
 		return err
 	})
 
@@ -382,10 +403,17 @@ func TestReactionsService_ListTeamDiscussionReactions(t *testing.T) {
 	if !reflect.DeepEqual(got, want) {
 		t.Errorf("ListTeamDiscussionReactions = %+v, want %+v", got, want)
 	}
+}
+
+func TestReactionsService_ListTeamDiscussionReactions_coverage(t *testing.T) {
+	client, _, _, teardown := setup()
+	defer teardown()
+
+	ctx := context.Background()
 
 	const methodName = "ListTeamDiscussionReactions"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.ListTeamDiscussionReactions(ctx, -1, -2, nil)
+		_, _, err = client.Reactions.ListTeamDiscussionReactions(ctx, -1, -2, &ListOptions{})
 		return err
 	})
 
@@ -456,12 +484,27 @@ func TestReactionService_ListTeamDiscussionCommentReactions(t *testing.T) {
 	if !reflect.DeepEqual(got, want) {
 		t.Errorf("ListTeamDiscussionCommentReactions = %+v, want %+v", got, want)
 	}
+}
+
+func TestReactionService_ListTeamDiscussionCommentReactions_coverage(t *testing.T) {
+	client, _, _, teardown := setup()
+	defer teardown()
+
+	ctx := context.Background()
 
 	const methodName = "ListTeamDiscussionCommentReactions"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Reactions.ListTeamDiscussionCommentReactions(ctx, -1, -2, -3, nil)
+		_, _, err = client.Reactions.ListTeamDiscussionCommentReactions(ctx, -1, -2, -3, &ListOptions{})
 		return err
 	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Reactions.ListTeamDiscussionCommentReactions(ctx, 1, 2, 3, nil)
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
 }
 
 func TestReactionService_CreateTeamDiscussionCommentReaction(t *testing.T) {