| 1 |
// Copyright 2016 The go-github AUTHORS. All rights reserved. |
| 2 |
// |
| 3 |
// Use of this source code is governed by a BSD-style |
| 4 |
// license that can be found in the LICENSE file. |
| 5 |
|
| 6 |
package github |
| 7 |
|
| 8 |
import ( |
| 9 |
"context" |
| 10 |
"fmt" |
| 11 |
"net/http" |
| 12 |
"testing" |
| 13 |
|
| 14 |
"github.com/google/go-cmp/cmp" |
| 15 |
) |
| 16 |
|
| 17 |
func TestReaction_Marshal(t *testing.T) { |
| 18 |
testJSONMarshal(t, &Reaction{}, "{}") |
| 19 |
|
| 20 |
r := &Reaction{ |
| 21 |
ID: Int64(1), |
| 22 |
User: nil, |
| 23 |
NodeID: String("n"), |
| 24 |
Content: String("+1"), |
| 25 |
} |
| 26 |
|
| 27 |
want := `{ |
| 28 |
"id": 1, |
| 29 |
"node_id": "n", |
| 30 |
"content": "+1" |
| 31 |
}` |
| 32 |
|
| 33 |
testJSONMarshal(t, r, want) |
| 34 |
} |
| 35 |
|
| 36 |
func TestReactions_Marshal(t *testing.T) { |
| 37 |
testJSONMarshal(t, &Reactions{}, "{}") |
| 38 |
|
| 39 |
r := &Reactions{ |
| 40 |
TotalCount: Int(1), |
| 41 |
PlusOne: Int(1), |
| 42 |
MinusOne: Int(1), |
| 43 |
Laugh: Int(1), |
| 44 |
Confused: Int(1), |
| 45 |
Heart: Int(1), |
| 46 |
Hooray: Int(1), |
| 47 |
Rocket: Int(1), |
| 48 |
Eyes: Int(1), |
| 49 |
URL: String("u"), |
| 50 |
} |
| 51 |
|
| 52 |
want := `{ |
| 53 |
"total_count": 1, |
| 54 |
"+1": 1, |
| 55 |
"-1": 1, |
| 56 |
"laugh": 1, |
| 57 |
"confused": 1, |
| 58 |
"heart": 1, |
| 59 |
"hooray": 1, |
| 60 |
"rocket": 1, |
| 61 |
"eyes": 1, |
| 62 |
"url": "u" |
| 63 |
}` |
| 64 |
|
| 65 |
testJSONMarshal(t, r, want) |
| 66 |
} |
| 67 |
|
| 68 |
func TestReactionsService_ListCommentReactions(t *testing.T) { |
| 69 |
client, mux, _, teardown := setup() |
| 70 |
defer teardown() |
| 71 |
|
| 72 |
mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 73 |
testMethod(t, r, "GET") |
| 74 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 75 |
|
| 76 |
testFormValues(t, r, values{"content": "+1"}) |
| 77 |
fmt.Fprint(w, `[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`) |
| 78 |
}) |
| 79 |
|
| 80 |
opt := &ListCommentReactionOptions{Content: "+1"} |
| 81 |
ctx := context.Background() |
| 82 |
reactions, _, err := client.Reactions.ListCommentReactions(ctx, "o", "r", 1, opt) |
| 83 |
if err != nil { |
| 84 |
t.Errorf("ListCommentReactions returned error: %v", err) |
| 85 |
} |
| 86 |
want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} |
| 87 |
if !cmp.Equal(reactions, want) { |
| 88 |
t.Errorf("ListCommentReactions = %+v, want %+v", reactions, want) |
| 89 |
} |
| 90 |
|
| 91 |
const methodName = "ListCommentReactions" |
| 92 |
testBadOptions(t, methodName, func() (err error) { |
| 93 |
_, _, err = client.Reactions.ListCommentReactions(ctx, "\n", "\n", -1, opt) |
| 94 |
return err |
| 95 |
}) |
| 96 |
|
| 97 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 98 |
got, resp, err := client.Reactions.ListCommentReactions(ctx, "o", "r", 1, opt) |
| 99 |
if got != nil { |
| 100 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 101 |
} |
| 102 |
return resp, err |
| 103 |
}) |
| 104 |
} |
| 105 |
|
| 106 |
func TestReactionsService_CreateCommentReaction(t *testing.T) { |
| 107 |
client, mux, _, teardown := setup() |
| 108 |
defer teardown() |
| 109 |
|
| 110 |
mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 111 |
testMethod(t, r, "POST") |
| 112 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 113 |
|
| 114 |
w.WriteHeader(http.StatusCreated) |
| 115 |
assertWrite(t, w, []byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) |
| 116 |
}) |
| 117 |
|
| 118 |
ctx := context.Background() |
| 119 |
got, _, err := client.Reactions.CreateCommentReaction(ctx, "o", "r", 1, "+1") |
| 120 |
if err != nil { |
| 121 |
t.Errorf("CreateCommentReaction returned error: %v", err) |
| 122 |
} |
| 123 |
want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")} |
| 124 |
if !cmp.Equal(got, want) { |
| 125 |
t.Errorf("CreateCommentReaction = %+v, want %+v", got, want) |
| 126 |
} |
| 127 |
|
| 128 |
const methodName = "CreateCommentReaction" |
| 129 |
testBadOptions(t, methodName, func() (err error) { |
| 130 |
_, _, err = client.Reactions.CreateCommentReaction(ctx, "\n", "\n", -1, "\n") |
| 131 |
return err |
| 132 |
}) |
| 133 |
|
| 134 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 135 |
got, resp, err := client.Reactions.CreateCommentReaction(ctx, "o", "r", 1, "+1") |
| 136 |
if got != nil { |
| 137 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 138 |
} |
| 139 |
return resp, err |
| 140 |
}) |
| 141 |
} |
| 142 |
|
| 143 |
func TestReactionsService_ListIssueReactions(t *testing.T) { |
| 144 |
client, mux, _, teardown := setup() |
| 145 |
defer teardown() |
| 146 |
|
| 147 |
mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 148 |
testMethod(t, r, "GET") |
| 149 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 150 |
|
| 151 |
w.WriteHeader(http.StatusOK) |
| 152 |
assertWrite(t, w, []byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) |
| 153 |
}) |
| 154 |
|
| 155 |
ctx := context.Background() |
| 156 |
got, _, err := client.Reactions.ListIssueReactions(ctx, "o", "r", 1, nil) |
| 157 |
if err != nil { |
| 158 |
t.Errorf("ListIssueReactions returned error: %v", err) |
| 159 |
} |
| 160 |
want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} |
| 161 |
if !cmp.Equal(got, want) { |
| 162 |
t.Errorf("ListIssueReactions = %+v, want %+v", got, want) |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
func TestReactionsService_ListIssueReactions_coverage(t *testing.T) { |
| 167 |
client, _, _, teardown := setup() |
| 168 |
defer teardown() |
| 169 |
|
| 170 |
ctx := context.Background() |
| 171 |
|
| 172 |
const methodName = "ListIssueReactions" |
| 173 |
testBadOptions(t, methodName, func() (err error) { |
| 174 |
_, _, err = client.Reactions.ListIssueReactions(ctx, "\n", "\n", -1, &ListOptions{}) |
| 175 |
return err |
| 176 |
}) |
| 177 |
|
| 178 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 179 |
got, resp, err := client.Reactions.ListIssueReactions(ctx, "o", "r", 1, nil) |
| 180 |
if got != nil { |
| 181 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 182 |
} |
| 183 |
return resp, err |
| 184 |
}) |
| 185 |
} |
| 186 |
|
| 187 |
func TestReactionsService_CreateIssueReaction(t *testing.T) { |
| 188 |
client, mux, _, teardown := setup() |
| 189 |
defer teardown() |
| 190 |
|
| 191 |
mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 192 |
testMethod(t, r, "POST") |
| 193 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 194 |
|
| 195 |
w.WriteHeader(http.StatusCreated) |
| 196 |
assertWrite(t, w, []byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) |
| 197 |
}) |
| 198 |
|
| 199 |
ctx := context.Background() |
| 200 |
got, _, err := client.Reactions.CreateIssueReaction(ctx, "o", "r", 1, "+1") |
| 201 |
if err != nil { |
| 202 |
t.Errorf("CreateIssueReaction returned error: %v", err) |
| 203 |
} |
| 204 |
want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")} |
| 205 |
if !cmp.Equal(got, want) { |
| 206 |
t.Errorf("CreateIssueReaction = %+v, want %+v", got, want) |
| 207 |
} |
| 208 |
|
| 209 |
const methodName = "CreateIssueReaction" |
| 210 |
testBadOptions(t, methodName, func() (err error) { |
| 211 |
_, _, err = client.Reactions.CreateIssueReaction(ctx, "\n", "\n", -1, "\n") |
| 212 |
return err |
| 213 |
}) |
| 214 |
|
| 215 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 216 |
got, resp, err := client.Reactions.CreateIssueReaction(ctx, "o", "r", 1, "+1") |
| 217 |
if got != nil { |
| 218 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 219 |
} |
| 220 |
return resp, err |
| 221 |
}) |
| 222 |
} |
| 223 |
|
| 224 |
func TestReactionsService_ListIssueCommentReactions(t *testing.T) { |
| 225 |
client, mux, _, teardown := setup() |
| 226 |
defer teardown() |
| 227 |
|
| 228 |
mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 229 |
testMethod(t, r, "GET") |
| 230 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 231 |
|
| 232 |
w.WriteHeader(http.StatusOK) |
| 233 |
assertWrite(t, w, []byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) |
| 234 |
}) |
| 235 |
|
| 236 |
ctx := context.Background() |
| 237 |
got, _, err := client.Reactions.ListIssueCommentReactions(ctx, "o", "r", 1, nil) |
| 238 |
if err != nil { |
| 239 |
t.Errorf("ListIssueCommentReactions returned error: %v", err) |
| 240 |
} |
| 241 |
want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} |
| 242 |
if !cmp.Equal(got, want) { |
| 243 |
t.Errorf("ListIssueCommentReactions = %+v, want %+v", got, want) |
| 244 |
} |
| 245 |
} |
| 246 |
|
| 247 |
func TestReactionsService_ListIssueCommentReactions_coverage(t *testing.T) { |
| 248 |
client, _, _, teardown := setup() |
| 249 |
defer teardown() |
| 250 |
|
| 251 |
ctx := context.Background() |
| 252 |
|
| 253 |
const methodName = "ListIssueCommentReactions" |
| 254 |
testBadOptions(t, methodName, func() (err error) { |
| 255 |
_, _, err = client.Reactions.ListIssueCommentReactions(ctx, "\n", "\n", -1, &ListOptions{}) |
| 256 |
return err |
| 257 |
}) |
| 258 |
|
| 259 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 260 |
got, resp, err := client.Reactions.ListIssueCommentReactions(ctx, "o", "r", 1, nil) |
| 261 |
if got != nil { |
| 262 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 263 |
} |
| 264 |
return resp, err |
| 265 |
}) |
| 266 |
} |
| 267 |
|
| 268 |
func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { |
| 269 |
client, mux, _, teardown := setup() |
| 270 |
defer teardown() |
| 271 |
|
| 272 |
mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 273 |
testMethod(t, r, "POST") |
| 274 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 275 |
|
| 276 |
w.WriteHeader(http.StatusCreated) |
| 277 |
assertWrite(t, w, []byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) |
| 278 |
}) |
| 279 |
|
| 280 |
ctx := context.Background() |
| 281 |
got, _, err := client.Reactions.CreateIssueCommentReaction(ctx, "o", "r", 1, "+1") |
| 282 |
if err != nil { |
| 283 |
t.Errorf("CreateIssueCommentReaction returned error: %v", err) |
| 284 |
} |
| 285 |
want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")} |
| 286 |
if !cmp.Equal(got, want) { |
| 287 |
t.Errorf("CreateIssueCommentReaction = %+v, want %+v", got, want) |
| 288 |
} |
| 289 |
|
| 290 |
const methodName = "CreateIssueCommentReaction" |
| 291 |
testBadOptions(t, methodName, func() (err error) { |
| 292 |
_, _, err = client.Reactions.CreateIssueCommentReaction(ctx, "\n", "\n", -1, "\n") |
| 293 |
return err |
| 294 |
}) |
| 295 |
|
| 296 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 297 |
got, resp, err := client.Reactions.CreateIssueCommentReaction(ctx, "o", "r", 1, "+1") |
| 298 |
if got != nil { |
| 299 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 300 |
} |
| 301 |
return resp, err |
| 302 |
}) |
| 303 |
} |
| 304 |
|
| 305 |
func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { |
| 306 |
client, mux, _, teardown := setup() |
| 307 |
defer teardown() |
| 308 |
|
| 309 |
mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 310 |
testMethod(t, r, "GET") |
| 311 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 312 |
|
| 313 |
w.WriteHeader(http.StatusOK) |
| 314 |
assertWrite(t, w, []byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) |
| 315 |
}) |
| 316 |
|
| 317 |
ctx := context.Background() |
| 318 |
got, _, err := client.Reactions.ListPullRequestCommentReactions(ctx, "o", "r", 1, nil) |
| 319 |
if err != nil { |
| 320 |
t.Errorf("ListPullRequestCommentReactions returned error: %v", err) |
| 321 |
} |
| 322 |
want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} |
| 323 |
if !cmp.Equal(got, want) { |
| 324 |
t.Errorf("ListPullRequestCommentReactions = %+v, want %+v", got, want) |
| 325 |
} |
| 326 |
} |
| 327 |
|
| 328 |
func TestReactionsService_ListPullRequestCommentReactions_coverage(t *testing.T) { |
| 329 |
client, _, _, teardown := setup() |
| 330 |
defer teardown() |
| 331 |
|
| 332 |
ctx := context.Background() |
| 333 |
|
| 334 |
const methodName = "ListPullRequestCommentReactions" |
| 335 |
testBadOptions(t, methodName, func() (err error) { |
| 336 |
_, _, err = client.Reactions.ListPullRequestCommentReactions(ctx, "\n", "\n", -1, &ListOptions{}) |
| 337 |
return err |
| 338 |
}) |
| 339 |
|
| 340 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 341 |
got, resp, err := client.Reactions.ListPullRequestCommentReactions(ctx, "o", "r", 1, nil) |
| 342 |
if got != nil { |
| 343 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 344 |
} |
| 345 |
return resp, err |
| 346 |
}) |
| 347 |
} |
| 348 |
|
| 349 |
func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { |
| 350 |
client, mux, _, teardown := setup() |
| 351 |
defer teardown() |
| 352 |
|
| 353 |
mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 354 |
testMethod(t, r, "POST") |
| 355 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 356 |
|
| 357 |
w.WriteHeader(http.StatusCreated) |
| 358 |
assertWrite(t, w, []byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) |
| 359 |
}) |
| 360 |
|
| 361 |
ctx := context.Background() |
| 362 |
got, _, err := client.Reactions.CreatePullRequestCommentReaction(ctx, "o", "r", 1, "+1") |
| 363 |
if err != nil { |
| 364 |
t.Errorf("CreatePullRequestCommentReaction returned error: %v", err) |
| 365 |
} |
| 366 |
want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")} |
| 367 |
if !cmp.Equal(got, want) { |
| 368 |
t.Errorf("CreatePullRequestCommentReaction = %+v, want %+v", got, want) |
| 369 |
} |
| 370 |
|
| 371 |
const methodName = "CreatePullRequestCommentReaction" |
| 372 |
testBadOptions(t, methodName, func() (err error) { |
| 373 |
_, _, err = client.Reactions.CreatePullRequestCommentReaction(ctx, "\n", "\n", -1, "\n") |
| 374 |
return err |
| 375 |
}) |
| 376 |
|
| 377 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 378 |
got, resp, err := client.Reactions.CreatePullRequestCommentReaction(ctx, "o", "r", 1, "+1") |
| 379 |
if got != nil { |
| 380 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 381 |
} |
| 382 |
return resp, err |
| 383 |
}) |
| 384 |
} |
| 385 |
|
| 386 |
func TestReactionsService_ListTeamDiscussionReactions(t *testing.T) { |
| 387 |
client, mux, _, teardown := setup() |
| 388 |
defer teardown() |
| 389 |
|
| 390 |
mux.HandleFunc("/teams/1/discussions/2/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 391 |
testMethod(t, r, "GET") |
| 392 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 393 |
|
| 394 |
w.WriteHeader(http.StatusOK) |
| 395 |
assertWrite(t, w, []byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) |
| 396 |
}) |
| 397 |
|
| 398 |
ctx := context.Background() |
| 399 |
got, _, err := client.Reactions.ListTeamDiscussionReactions(ctx, 1, 2, nil) |
| 400 |
if err != nil { |
| 401 |
t.Errorf("ListTeamDiscussionReactions returned error: %v", err) |
| 402 |
} |
| 403 |
want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} |
| 404 |
if !cmp.Equal(got, want) { |
| 405 |
t.Errorf("ListTeamDiscussionReactions = %+v, want %+v", got, want) |
| 406 |
} |
| 407 |
} |
| 408 |
|
| 409 |
func TestReactionsService_ListTeamDiscussionReactions_coverage(t *testing.T) { |
| 410 |
client, _, _, teardown := setup() |
| 411 |
defer teardown() |
| 412 |
|
| 413 |
ctx := context.Background() |
| 414 |
|
| 415 |
const methodName = "ListTeamDiscussionReactions" |
| 416 |
testBadOptions(t, methodName, func() (err error) { |
| 417 |
_, _, err = client.Reactions.ListTeamDiscussionReactions(ctx, -1, -2, &ListOptions{}) |
| 418 |
return err |
| 419 |
}) |
| 420 |
|
| 421 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 422 |
got, resp, err := client.Reactions.ListTeamDiscussionReactions(ctx, 1, 2, nil) |
| 423 |
if got != nil { |
| 424 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 425 |
} |
| 426 |
return resp, err |
| 427 |
}) |
| 428 |
} |
| 429 |
|
| 430 |
func TestReactionsService_CreateTeamDiscussionReaction(t *testing.T) { |
| 431 |
client, mux, _, teardown := setup() |
| 432 |
defer teardown() |
| 433 |
|
| 434 |
mux.HandleFunc("/teams/1/discussions/2/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 435 |
testMethod(t, r, "POST") |
| 436 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 437 |
|
| 438 |
w.WriteHeader(http.StatusCreated) |
| 439 |
assertWrite(t, w, []byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) |
| 440 |
}) |
| 441 |
|
| 442 |
ctx := context.Background() |
| 443 |
got, _, err := client.Reactions.CreateTeamDiscussionReaction(ctx, 1, 2, "+1") |
| 444 |
if err != nil { |
| 445 |
t.Errorf("CreateTeamDiscussionReaction returned error: %v", err) |
| 446 |
} |
| 447 |
want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")} |
| 448 |
if !cmp.Equal(got, want) { |
| 449 |
t.Errorf("CreateTeamDiscussionReaction = %+v, want %+v", got, want) |
| 450 |
} |
| 451 |
|
| 452 |
const methodName = "CreateTeamDiscussionReaction" |
| 453 |
testBadOptions(t, methodName, func() (err error) { |
| 454 |
_, _, err = client.Reactions.CreateTeamDiscussionReaction(ctx, -1, -2, "\n") |
| 455 |
return err |
| 456 |
}) |
| 457 |
|
| 458 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 459 |
got, resp, err := client.Reactions.CreateTeamDiscussionReaction(ctx, 1, 2, "+1") |
| 460 |
if got != nil { |
| 461 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 462 |
} |
| 463 |
return resp, err |
| 464 |
}) |
| 465 |
} |
| 466 |
|
| 467 |
func TestReactionService_ListTeamDiscussionCommentReactions(t *testing.T) { |
| 468 |
client, mux, _, teardown := setup() |
| 469 |
defer teardown() |
| 470 |
|
| 471 |
mux.HandleFunc("/teams/1/discussions/2/comments/3/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 472 |
testMethod(t, r, "GET") |
| 473 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 474 |
|
| 475 |
w.WriteHeader(http.StatusOK) |
| 476 |
assertWrite(t, w, []byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) |
| 477 |
}) |
| 478 |
|
| 479 |
ctx := context.Background() |
| 480 |
got, _, err := client.Reactions.ListTeamDiscussionCommentReactions(ctx, 1, 2, 3, nil) |
| 481 |
if err != nil { |
| 482 |
t.Errorf("ListTeamDiscussionCommentReactions returned error: %v", err) |
| 483 |
} |
| 484 |
want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} |
| 485 |
if !cmp.Equal(got, want) { |
| 486 |
t.Errorf("ListTeamDiscussionCommentReactions = %+v, want %+v", got, want) |
| 487 |
} |
| 488 |
} |
| 489 |
|
| 490 |
func TestReactionService_ListTeamDiscussionCommentReactions_coverage(t *testing.T) { |
| 491 |
client, _, _, teardown := setup() |
| 492 |
defer teardown() |
| 493 |
|
| 494 |
ctx := context.Background() |
| 495 |
|
| 496 |
const methodName = "ListTeamDiscussionCommentReactions" |
| 497 |
testBadOptions(t, methodName, func() (err error) { |
| 498 |
_, _, err = client.Reactions.ListTeamDiscussionCommentReactions(ctx, -1, -2, -3, &ListOptions{}) |
| 499 |
return err |
| 500 |
}) |
| 501 |
|
| 502 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 503 |
got, resp, err := client.Reactions.ListTeamDiscussionCommentReactions(ctx, 1, 2, 3, nil) |
| 504 |
if got != nil { |
| 505 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 506 |
} |
| 507 |
return resp, err |
| 508 |
}) |
| 509 |
} |
| 510 |
|
| 511 |
func TestReactionService_CreateTeamDiscussionCommentReaction(t *testing.T) { |
| 512 |
client, mux, _, teardown := setup() |
| 513 |
defer teardown() |
| 514 |
|
| 515 |
mux.HandleFunc("/teams/1/discussions/2/comments/3/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 516 |
testMethod(t, r, "POST") |
| 517 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 518 |
|
| 519 |
w.WriteHeader(http.StatusCreated) |
| 520 |
assertWrite(t, w, []byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) |
| 521 |
}) |
| 522 |
|
| 523 |
ctx := context.Background() |
| 524 |
got, _, err := client.Reactions.CreateTeamDiscussionCommentReaction(ctx, 1, 2, 3, "+1") |
| 525 |
if err != nil { |
| 526 |
t.Errorf("CreateTeamDiscussionCommentReaction returned error: %v", err) |
| 527 |
} |
| 528 |
want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")} |
| 529 |
if !cmp.Equal(got, want) { |
| 530 |
t.Errorf("CreateTeamDiscussionCommentReaction = %+v, want %+v", got, want) |
| 531 |
} |
| 532 |
|
| 533 |
const methodName = "CreateTeamDiscussionCommentReaction" |
| 534 |
testBadOptions(t, methodName, func() (err error) { |
| 535 |
_, _, err = client.Reactions.CreateTeamDiscussionCommentReaction(ctx, -1, -2, -3, "\n") |
| 536 |
return err |
| 537 |
}) |
| 538 |
|
| 539 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 540 |
got, resp, err := client.Reactions.CreateTeamDiscussionCommentReaction(ctx, 1, 2, 3, "+1") |
| 541 |
if got != nil { |
| 542 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 543 |
} |
| 544 |
return resp, err |
| 545 |
}) |
| 546 |
} |
| 547 |
|
| 548 |
func TestReactionsService_DeleteCommitCommentReaction(t *testing.T) { |
| 549 |
client, mux, _, teardown := setup() |
| 550 |
defer teardown() |
| 551 |
|
| 552 |
mux.HandleFunc("/repos/o/r/comments/1/reactions/2", func(w http.ResponseWriter, r *http.Request) { |
| 553 |
testMethod(t, r, "DELETE") |
| 554 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 555 |
|
| 556 |
w.WriteHeader(http.StatusNoContent) |
| 557 |
}) |
| 558 |
|
| 559 |
ctx := context.Background() |
| 560 |
if _, err := client.Reactions.DeleteCommentReaction(ctx, "o", "r", 1, 2); err != nil { |
| 561 |
t.Errorf("DeleteCommentReaction returned error: %v", err) |
| 562 |
} |
| 563 |
|
| 564 |
const methodName = "DeleteCommentReaction" |
| 565 |
testBadOptions(t, methodName, func() (err error) { |
| 566 |
_, err = client.Reactions.DeleteCommentReaction(ctx, "\n", "\n", -1, -2) |
| 567 |
return err |
| 568 |
}) |
| 569 |
|
| 570 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 571 |
return client.Reactions.DeleteCommentReaction(ctx, "o", "r", 1, 2) |
| 572 |
}) |
| 573 |
} |
| 574 |
|
| 575 |
func TestReactionsService_DeleteCommitCommentReactionByRepoID(t *testing.T) { |
| 576 |
client, mux, _, teardown := setup() |
| 577 |
defer teardown() |
| 578 |
|
| 579 |
mux.HandleFunc("/repositories/1/comments/2/reactions/3", func(w http.ResponseWriter, r *http.Request) { |
| 580 |
testMethod(t, r, "DELETE") |
| 581 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 582 |
|
| 583 |
w.WriteHeader(http.StatusNoContent) |
| 584 |
}) |
| 585 |
|
| 586 |
ctx := context.Background() |
| 587 |
if _, err := client.Reactions.DeleteCommentReactionByID(ctx, 1, 2, 3); err != nil { |
| 588 |
t.Errorf("DeleteCommentReactionByRepoID returned error: %v", err) |
| 589 |
} |
| 590 |
|
| 591 |
const methodName = "DeleteCommentReactionByID" |
| 592 |
testBadOptions(t, methodName, func() (err error) { |
| 593 |
_, err = client.Reactions.DeleteCommentReactionByID(ctx, -1, -2, -3) |
| 594 |
return err |
| 595 |
}) |
| 596 |
|
| 597 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 598 |
return client.Reactions.DeleteCommentReactionByID(ctx, 1, 2, 3) |
| 599 |
}) |
| 600 |
} |
| 601 |
|
| 602 |
func TestReactionsService_DeleteIssueReaction(t *testing.T) { |
| 603 |
client, mux, _, teardown := setup() |
| 604 |
defer teardown() |
| 605 |
|
| 606 |
mux.HandleFunc("/repos/o/r/issues/1/reactions/2", func(w http.ResponseWriter, r *http.Request) { |
| 607 |
testMethod(t, r, "DELETE") |
| 608 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 609 |
|
| 610 |
w.WriteHeader(http.StatusNoContent) |
| 611 |
}) |
| 612 |
|
| 613 |
ctx := context.Background() |
| 614 |
if _, err := client.Reactions.DeleteIssueReaction(ctx, "o", "r", 1, 2); err != nil { |
| 615 |
t.Errorf("DeleteIssueReaction returned error: %v", err) |
| 616 |
} |
| 617 |
|
| 618 |
const methodName = "DeleteIssueReaction" |
| 619 |
testBadOptions(t, methodName, func() (err error) { |
| 620 |
_, err = client.Reactions.DeleteIssueReaction(ctx, "\n", "\n", -1, -2) |
| 621 |
return err |
| 622 |
}) |
| 623 |
|
| 624 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 625 |
return client.Reactions.DeleteIssueReaction(ctx, "o", "r", 1, 2) |
| 626 |
}) |
| 627 |
} |
| 628 |
|
| 629 |
func TestReactionsService_DeleteIssueReactionByRepoID(t *testing.T) { |
| 630 |
client, mux, _, teardown := setup() |
| 631 |
defer teardown() |
| 632 |
|
| 633 |
mux.HandleFunc("/repositories/1/issues/2/reactions/3", func(w http.ResponseWriter, r *http.Request) { |
| 634 |
testMethod(t, r, "DELETE") |
| 635 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 636 |
|
| 637 |
w.WriteHeader(http.StatusNoContent) |
| 638 |
}) |
| 639 |
|
| 640 |
ctx := context.Background() |
| 641 |
if _, err := client.Reactions.DeleteIssueReactionByID(ctx, 1, 2, 3); err != nil { |
| 642 |
t.Errorf("DeleteIssueReactionByRepoID returned error: %v", err) |
| 643 |
} |
| 644 |
|
| 645 |
const methodName = "DeleteIssueReactionByID" |
| 646 |
testBadOptions(t, methodName, func() (err error) { |
| 647 |
_, err = client.Reactions.DeleteIssueReactionByID(ctx, -1, -2, -3) |
| 648 |
return err |
| 649 |
}) |
| 650 |
|
| 651 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 652 |
return client.Reactions.DeleteIssueReactionByID(ctx, 1, 2, 3) |
| 653 |
}) |
| 654 |
} |
| 655 |
|
| 656 |
func TestReactionsService_DeleteIssueCommentReaction(t *testing.T) { |
| 657 |
client, mux, _, teardown := setup() |
| 658 |
defer teardown() |
| 659 |
|
| 660 |
mux.HandleFunc("/repos/o/r/issues/comments/1/reactions/2", func(w http.ResponseWriter, r *http.Request) { |
| 661 |
testMethod(t, r, "DELETE") |
| 662 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 663 |
|
| 664 |
w.WriteHeader(http.StatusNoContent) |
| 665 |
}) |
| 666 |
|
| 667 |
ctx := context.Background() |
| 668 |
if _, err := client.Reactions.DeleteIssueCommentReaction(ctx, "o", "r", 1, 2); err != nil { |
| 669 |
t.Errorf("DeleteIssueCommentReaction returned error: %v", err) |
| 670 |
} |
| 671 |
|
| 672 |
const methodName = "DeleteIssueCommentReaction" |
| 673 |
testBadOptions(t, methodName, func() (err error) { |
| 674 |
_, err = client.Reactions.DeleteIssueCommentReaction(ctx, "\n", "\n", -1, -2) |
| 675 |
return err |
| 676 |
}) |
| 677 |
|
| 678 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 679 |
return client.Reactions.DeleteIssueCommentReaction(ctx, "o", "r", 1, 2) |
| 680 |
}) |
| 681 |
} |
| 682 |
|
| 683 |
func TestReactionsService_DeleteIssueCommentReactionByRepoID(t *testing.T) { |
| 684 |
client, mux, _, teardown := setup() |
| 685 |
defer teardown() |
| 686 |
|
| 687 |
mux.HandleFunc("/repositories/1/issues/comments/2/reactions/3", func(w http.ResponseWriter, r *http.Request) { |
| 688 |
testMethod(t, r, "DELETE") |
| 689 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 690 |
|
| 691 |
w.WriteHeader(http.StatusNoContent) |
| 692 |
}) |
| 693 |
|
| 694 |
ctx := context.Background() |
| 695 |
if _, err := client.Reactions.DeleteIssueCommentReactionByID(ctx, 1, 2, 3); err != nil { |
| 696 |
t.Errorf("DeleteIssueCommentReactionByRepoID returned error: %v", err) |
| 697 |
} |
| 698 |
|
| 699 |
const methodName = "DeleteIssueCommentReactionByID" |
| 700 |
testBadOptions(t, methodName, func() (err error) { |
| 701 |
_, err = client.Reactions.DeleteIssueCommentReactionByID(ctx, -1, -2, -3) |
| 702 |
return err |
| 703 |
}) |
| 704 |
|
| 705 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 706 |
return client.Reactions.DeleteIssueCommentReactionByID(ctx, 1, 2, 3) |
| 707 |
}) |
| 708 |
} |
| 709 |
|
| 710 |
func TestReactionsService_DeletePullRequestCommentReaction(t *testing.T) { |
| 711 |
client, mux, _, teardown := setup() |
| 712 |
defer teardown() |
| 713 |
|
| 714 |
mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions/2", func(w http.ResponseWriter, r *http.Request) { |
| 715 |
testMethod(t, r, "DELETE") |
| 716 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 717 |
|
| 718 |
w.WriteHeader(http.StatusNoContent) |
| 719 |
}) |
| 720 |
|
| 721 |
ctx := context.Background() |
| 722 |
if _, err := client.Reactions.DeletePullRequestCommentReaction(ctx, "o", "r", 1, 2); err != nil { |
| 723 |
t.Errorf("DeletePullRequestCommentReaction returned error: %v", err) |
| 724 |
} |
| 725 |
|
| 726 |
const methodName = "DeletePullRequestCommentReaction" |
| 727 |
testBadOptions(t, methodName, func() (err error) { |
| 728 |
_, err = client.Reactions.DeletePullRequestCommentReaction(ctx, "\n", "\n", -1, -2) |
| 729 |
return err |
| 730 |
}) |
| 731 |
|
| 732 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 733 |
return client.Reactions.DeletePullRequestCommentReaction(ctx, "o", "r", 1, 2) |
| 734 |
}) |
| 735 |
} |
| 736 |
|
| 737 |
func TestReactionsService_DeletePullRequestCommentReactionByRepoID(t *testing.T) { |
| 738 |
client, mux, _, teardown := setup() |
| 739 |
defer teardown() |
| 740 |
|
| 741 |
mux.HandleFunc("/repositories/1/pulls/comments/2/reactions/3", func(w http.ResponseWriter, r *http.Request) { |
| 742 |
testMethod(t, r, "DELETE") |
| 743 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 744 |
|
| 745 |
w.WriteHeader(http.StatusNoContent) |
| 746 |
}) |
| 747 |
|
| 748 |
ctx := context.Background() |
| 749 |
if _, err := client.Reactions.DeletePullRequestCommentReactionByID(ctx, 1, 2, 3); err != nil { |
| 750 |
t.Errorf("DeletePullRequestCommentReactionByRepoID returned error: %v", err) |
| 751 |
} |
| 752 |
|
| 753 |
const methodName = "DeletePullRequestCommentReactionByID" |
| 754 |
testBadOptions(t, methodName, func() (err error) { |
| 755 |
_, err = client.Reactions.DeletePullRequestCommentReactionByID(ctx, -1, -2, -3) |
| 756 |
return err |
| 757 |
}) |
| 758 |
|
| 759 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 760 |
return client.Reactions.DeletePullRequestCommentReactionByID(ctx, 1, 2, 3) |
| 761 |
}) |
| 762 |
} |
| 763 |
|
| 764 |
func TestReactionsService_DeleteTeamDiscussionReaction(t *testing.T) { |
| 765 |
client, mux, _, teardown := setup() |
| 766 |
defer teardown() |
| 767 |
|
| 768 |
mux.HandleFunc("/orgs/o/teams/s/discussions/1/reactions/2", func(w http.ResponseWriter, r *http.Request) { |
| 769 |
testMethod(t, r, "DELETE") |
| 770 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 771 |
|
| 772 |
w.WriteHeader(http.StatusNoContent) |
| 773 |
}) |
| 774 |
|
| 775 |
ctx := context.Background() |
| 776 |
if _, err := client.Reactions.DeleteTeamDiscussionReaction(ctx, "o", "s", 1, 2); err != nil { |
| 777 |
t.Errorf("DeleteTeamDiscussionReaction returned error: %v", err) |
| 778 |
} |
| 779 |
|
| 780 |
const methodName = "DeleteTeamDiscussionReaction" |
| 781 |
testBadOptions(t, methodName, func() (err error) { |
| 782 |
_, err = client.Reactions.DeleteTeamDiscussionReaction(ctx, "\n", "\n", -1, -2) |
| 783 |
return err |
| 784 |
}) |
| 785 |
|
| 786 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 787 |
return client.Reactions.DeleteTeamDiscussionReaction(ctx, "o", "s", 1, 2) |
| 788 |
}) |
| 789 |
} |
| 790 |
|
| 791 |
func TestReactionsService_DeleteTeamDiscussionReactionByTeamIDAndOrgID(t *testing.T) { |
| 792 |
client, mux, _, teardown := setup() |
| 793 |
defer teardown() |
| 794 |
|
| 795 |
mux.HandleFunc("/organizations/1/team/2/discussions/3/reactions/4", func(w http.ResponseWriter, r *http.Request) { |
| 796 |
testMethod(t, r, "DELETE") |
| 797 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 798 |
|
| 799 |
w.WriteHeader(http.StatusNoContent) |
| 800 |
}) |
| 801 |
|
| 802 |
ctx := context.Background() |
| 803 |
if _, err := client.Reactions.DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx, 1, 2, 3, 4); err != nil { |
| 804 |
t.Errorf("DeleteTeamDiscussionReactionByTeamIDAndOrgID returned error: %v", err) |
| 805 |
} |
| 806 |
|
| 807 |
const methodName = "DeleteTeamDiscussionReactionByOrgIDAndTeamID" |
| 808 |
testBadOptions(t, methodName, func() (err error) { |
| 809 |
_, err = client.Reactions.DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx, -1, -2, -3, -4) |
| 810 |
return err |
| 811 |
}) |
| 812 |
|
| 813 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 814 |
return client.Reactions.DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx, 1, 2, 3, 4) |
| 815 |
}) |
| 816 |
} |
| 817 |
|
| 818 |
func TestReactionsService_DeleteTeamDiscussionCommentReaction(t *testing.T) { |
| 819 |
client, mux, _, teardown := setup() |
| 820 |
defer teardown() |
| 821 |
|
| 822 |
mux.HandleFunc("/orgs/o/teams/s/discussions/1/comments/2/reactions/3", func(w http.ResponseWriter, r *http.Request) { |
| 823 |
testMethod(t, r, "DELETE") |
| 824 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 825 |
|
| 826 |
w.WriteHeader(http.StatusNoContent) |
| 827 |
}) |
| 828 |
|
| 829 |
ctx := context.Background() |
| 830 |
if _, err := client.Reactions.DeleteTeamDiscussionCommentReaction(ctx, "o", "s", 1, 2, 3); err != nil { |
| 831 |
t.Errorf("DeleteTeamDiscussionCommentReaction returned error: %v", err) |
| 832 |
} |
| 833 |
|
| 834 |
const methodName = "DeleteTeamDiscussionCommentReaction" |
| 835 |
testBadOptions(t, methodName, func() (err error) { |
| 836 |
_, err = client.Reactions.DeleteTeamDiscussionCommentReaction(ctx, "\n", "\n", -1, -2, -3) |
| 837 |
return err |
| 838 |
}) |
| 839 |
|
| 840 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 841 |
return client.Reactions.DeleteTeamDiscussionCommentReaction(ctx, "o", "s", 1, 2, 3) |
| 842 |
}) |
| 843 |
} |
| 844 |
|
| 845 |
func TestReactionsService_DeleteTeamDiscussionCommentReactionByTeamIDAndOrgID(t *testing.T) { |
| 846 |
client, mux, _, teardown := setup() |
| 847 |
defer teardown() |
| 848 |
|
| 849 |
mux.HandleFunc("/organizations/1/team/2/discussions/3/comments/4/reactions/5", func(w http.ResponseWriter, r *http.Request) { |
| 850 |
testMethod(t, r, "DELETE") |
| 851 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 852 |
|
| 853 |
w.WriteHeader(http.StatusNoContent) |
| 854 |
}) |
| 855 |
|
| 856 |
ctx := context.Background() |
| 857 |
if _, err := client.Reactions.DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID(ctx, 1, 2, 3, 4, 5); err != nil { |
| 858 |
t.Errorf("DeleteTeamDiscussionCommentReactionByTeamIDAndOrgID returned error: %v", err) |
| 859 |
} |
| 860 |
|
| 861 |
const methodName = "DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID" |
| 862 |
testBadOptions(t, methodName, func() (err error) { |
| 863 |
_, err = client.Reactions.DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID(ctx, -1, -2, -3, -4, -5) |
| 864 |
return err |
| 865 |
}) |
| 866 |
|
| 867 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 868 |
return client.Reactions.DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID(ctx, 1, 2, 3, 4, 5) |
| 869 |
}) |
| 870 |
} |
| 871 |
|
| 872 |
func TestReactionService_CreateReleaseReaction(t *testing.T) { |
| 873 |
client, mux, _, teardown := setup() |
| 874 |
defer teardown() |
| 875 |
|
| 876 |
mux.HandleFunc("/repos/o/r/releases/1/reactions", func(w http.ResponseWriter, r *http.Request) { |
| 877 |
testMethod(t, r, "POST") |
| 878 |
testHeader(t, r, "Accept", mediaTypeReactionsPreview) |
| 879 |
|
| 880 |
w.WriteHeader(http.StatusCreated) |
| 881 |
assertWrite(t, w, []byte(`{"id":1,"user":{"login":"l","id":2},"content":"rocket"}`)) |
| 882 |
}) |
| 883 |
|
| 884 |
const methodName = "CreateReleaseReaction" |
| 885 |
ctx := context.Background() |
| 886 |
got, _, err := client.Reactions.CreateReleaseReaction(ctx, "o", "r", 1, "rocket") |
| 887 |
if err != nil { |
| 888 |
t.Errorf("%v returned error: %v", methodName, err) |
| 889 |
} |
| 890 |
|
| 891 |
want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("rocket")} |
| 892 |
if !cmp.Equal(got, want) { |
| 893 |
t.Errorf("%v = %+v, want %+v", methodName, got, want) |
| 894 |
} |
| 895 |
|
| 896 |
testBadOptions(t, methodName, func() (err error) { |
| 897 |
_, _, err = client.Reactions.CreateReleaseReaction(ctx, "\n", "\n", -1, "\n") |
| 898 |
return err |
| 899 |
}) |
| 900 |
|
| 901 |
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 902 |
got, resp, err := client.Reactions.CreateReleaseReaction(ctx, "o", "r", 1, "rocket") |
| 903 |
if got != nil { |
| 904 |
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 905 |
} |
| 906 |
return resp, err |
| 907 |
}) |
| 908 |
} |