github.com/google/go-github/v65@v65.0.0/github/actions_workflow_runs_test.go (about) 1 // Copyright 2020 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 "encoding/json" 11 "fmt" 12 "net/http" 13 "net/url" 14 "testing" 15 "time" 16 17 "github.com/google/go-cmp/cmp" 18 ) 19 20 func TestActionsService_ListWorkflowRunsByID(t *testing.T) { 21 client, mux, _, teardown := setup() 22 defer teardown() 23 24 mux.HandleFunc("/repos/o/r/actions/workflows/29679449/runs", func(w http.ResponseWriter, r *http.Request) { 25 testMethod(t, r, "GET") 26 testFormValues(t, r, values{"per_page": "2", "page": "2"}) 27 fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"id":399444497,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) 28 }) 29 30 opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} 31 ctx := context.Background() 32 runs, _, err := client.Actions.ListWorkflowRunsByID(ctx, "o", "r", 29679449, opts) 33 if err != nil { 34 t.Errorf("Actions.ListWorkFlowRunsByID returned error: %v", err) 35 } 36 37 want := &WorkflowRuns{ 38 TotalCount: Int(4), 39 WorkflowRuns: []*WorkflowRun{ 40 {ID: Int64(399444496), RunNumber: Int(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, 41 {ID: Int64(399444497), RunNumber: Int(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, 42 }, 43 } 44 if !cmp.Equal(runs, want) { 45 t.Errorf("Actions.ListWorkflowRunsByID returned %+v, want %+v", runs, want) 46 } 47 48 const methodName = "ListWorkflowRunsByID" 49 testBadOptions(t, methodName, func() (err error) { 50 _, _, err = client.Actions.ListWorkflowRunsByID(ctx, "\n", "\n", 29679449, opts) 51 return err 52 }) 53 54 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 55 got, resp, err := client.Actions.ListWorkflowRunsByID(ctx, "o", "r", 29679449, opts) 56 if got != nil { 57 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 58 } 59 return resp, err 60 }) 61 } 62 63 func TestActionsService_ListWorkflowRunsFileName(t *testing.T) { 64 client, mux, _, teardown := setup() 65 defer teardown() 66 67 mux.HandleFunc("/repos/o/r/actions/workflows/29679449/runs", func(w http.ResponseWriter, r *http.Request) { 68 testMethod(t, r, "GET") 69 testFormValues(t, r, values{"per_page": "2", "page": "2"}) 70 fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"id":399444497,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) 71 }) 72 73 opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} 74 ctx := context.Background() 75 runs, _, err := client.Actions.ListWorkflowRunsByFileName(ctx, "o", "r", "29679449", opts) 76 if err != nil { 77 t.Errorf("Actions.ListWorkFlowRunsByFileName returned error: %v", err) 78 } 79 80 want := &WorkflowRuns{ 81 TotalCount: Int(4), 82 WorkflowRuns: []*WorkflowRun{ 83 {ID: Int64(399444496), RunNumber: Int(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, 84 {ID: Int64(399444497), RunNumber: Int(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, 85 }, 86 } 87 if !cmp.Equal(runs, want) { 88 t.Errorf("Actions.ListWorkflowRunsByFileName returned %+v, want %+v", runs, want) 89 } 90 91 const methodName = "ListWorkflowRunsByFileName" 92 testBadOptions(t, methodName, func() (err error) { 93 _, _, err = client.Actions.ListWorkflowRunsByFileName(ctx, "\n", "\n", "29679449", opts) 94 return err 95 }) 96 97 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 98 got, resp, err := client.Actions.ListWorkflowRunsByFileName(ctx, "o", "r", "29679449", opts) 99 if got != nil { 100 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 101 } 102 return resp, err 103 }) 104 } 105 106 func TestActionsService_GetWorkflowRunByID(t *testing.T) { 107 client, mux, _, teardown := setup() 108 defer teardown() 109 110 mux.HandleFunc("/repos/o/r/actions/runs/29679449", func(w http.ResponseWriter, r *http.Request) { 111 testMethod(t, r, "GET") 112 fmt.Fprint(w, `{"id":399444496,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}}`) 113 }) 114 115 ctx := context.Background() 116 runs, _, err := client.Actions.GetWorkflowRunByID(ctx, "o", "r", 29679449) 117 if err != nil { 118 t.Errorf("Actions.GetWorkflowRunByID returned error: %v", err) 119 } 120 121 want := &WorkflowRun{ 122 ID: Int64(399444496), 123 RunNumber: Int(296), 124 CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, 125 UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, 126 } 127 128 if !cmp.Equal(runs, want) { 129 t.Errorf("Actions.GetWorkflowRunByID returned %+v, want %+v", runs, want) 130 } 131 132 const methodName = "GetWorkflowRunByID" 133 testBadOptions(t, methodName, func() (err error) { 134 _, _, err = client.Actions.GetWorkflowRunByID(ctx, "\n", "\n", 29679449) 135 return err 136 }) 137 138 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 139 got, resp, err := client.Actions.GetWorkflowRunByID(ctx, "o", "r", 29679449) 140 if got != nil { 141 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 142 } 143 return resp, err 144 }) 145 } 146 147 func TestActionsService_GetWorkflowRunAttempt(t *testing.T) { 148 client, mux, _, teardown := setup() 149 defer teardown() 150 151 mux.HandleFunc("/repos/o/r/actions/runs/29679449/attempts/3", func(w http.ResponseWriter, r *http.Request) { 152 testMethod(t, r, "GET") 153 testFormValues(t, r, values{"exclude_pull_requests": "true"}) 154 fmt.Fprint(w, `{"id":399444496,"run_number":296,"run_attempt":3,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}}`) 155 }) 156 157 opts := &WorkflowRunAttemptOptions{ExcludePullRequests: Bool(true)} 158 ctx := context.Background() 159 runs, _, err := client.Actions.GetWorkflowRunAttempt(ctx, "o", "r", 29679449, 3, opts) 160 if err != nil { 161 t.Errorf("Actions.GetWorkflowRunAttempt returned error: %v", err) 162 } 163 164 want := &WorkflowRun{ 165 ID: Int64(399444496), 166 RunNumber: Int(296), 167 RunAttempt: Int(3), 168 CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, 169 UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, 170 } 171 172 if !cmp.Equal(runs, want) { 173 t.Errorf("Actions.GetWorkflowRunAttempt returned %+v, want %+v", runs, want) 174 } 175 176 const methodName = "GetWorkflowRunAttempt" 177 testBadOptions(t, methodName, func() (err error) { 178 _, _, err = client.Actions.GetWorkflowRunAttempt(ctx, "\n", "\n", 29679449, 3, opts) 179 return err 180 }) 181 182 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 183 got, resp, err := client.Actions.GetWorkflowRunAttempt(ctx, "o", "r", 29679449, 3, opts) 184 if got != nil { 185 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 186 } 187 return resp, err 188 }) 189 } 190 191 func TestActionsService_GetWorkflowRunAttemptLogs(t *testing.T) { 192 client, mux, _, teardown := setup() 193 defer teardown() 194 195 mux.HandleFunc("/repos/o/r/actions/runs/399444496/attempts/2/logs", func(w http.ResponseWriter, r *http.Request) { 196 testMethod(t, r, "GET") 197 http.Redirect(w, r, "http://github.com/a", http.StatusFound) 198 }) 199 200 ctx := context.Background() 201 url, resp, err := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 1) 202 if err != nil { 203 t.Errorf("Actions.GetWorkflowRunAttemptLogs returned error: %v", err) 204 } 205 if resp.StatusCode != http.StatusFound { 206 t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) 207 } 208 want := "http://github.com/a" 209 if url.String() != want { 210 t.Errorf("Actions.GetWorkflowRunAttemptLogs returned %+v, want %+v", url.String(), want) 211 } 212 213 const methodName = "GetWorkflowRunAttemptLogs" 214 testBadOptions(t, methodName, func() (err error) { 215 _, _, err = client.Actions.GetWorkflowRunAttemptLogs(ctx, "\n", "\n", 399444496, 2, 1) 216 return err 217 }) 218 } 219 220 func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_dontFollowRedirects(t *testing.T) { 221 client, mux, _, teardown := setup() 222 defer teardown() 223 224 mux.HandleFunc("/repos/o/r/actions/runs/399444496/attempts/2/logs", func(w http.ResponseWriter, r *http.Request) { 225 testMethod(t, r, "GET") 226 http.Redirect(w, r, "http://github.com/a", http.StatusMovedPermanently) 227 }) 228 229 ctx := context.Background() 230 _, resp, _ := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 0) 231 if resp.StatusCode != http.StatusMovedPermanently { 232 t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently) 233 } 234 } 235 236 func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_followRedirects(t *testing.T) { 237 client, mux, serverURL, teardown := setup() 238 defer teardown() 239 240 // Mock a redirect link, which leads to an archive link 241 mux.HandleFunc("/repos/o/r/actions/runs/399444496/attempts/2/logs", func(w http.ResponseWriter, r *http.Request) { 242 testMethod(t, r, "GET") 243 redirectURL, _ := url.Parse(serverURL + baseURLPath + "/redirect") 244 http.Redirect(w, r, redirectURL.String(), http.StatusMovedPermanently) 245 }) 246 247 mux.HandleFunc("/redirect", func(w http.ResponseWriter, r *http.Request) { 248 testMethod(t, r, "GET") 249 http.Redirect(w, r, "http://github.com/a", http.StatusFound) 250 }) 251 252 ctx := context.Background() 253 url, resp, err := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 1) 254 if err != nil { 255 t.Errorf("Actions.GetWorkflowRunAttemptLogs returned error: %v", err) 256 } 257 258 if resp.StatusCode != http.StatusFound { 259 t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) 260 } 261 262 want := "http://github.com/a" 263 if url.String() != want { 264 t.Errorf("Actions.GetWorkflowRunAttemptLogs returned %+v, want %+v", url.String(), want) 265 } 266 267 const methodName = "GetWorkflowRunAttemptLogs" 268 testBadOptions(t, methodName, func() (err error) { 269 _, _, err = client.Actions.GetWorkflowRunAttemptLogs(ctx, "\n", "\n", 399444496, 2, 1) 270 return err 271 }) 272 } 273 274 func TestActionsService_RerunWorkflowRunByID(t *testing.T) { 275 client, mux, _, teardown := setup() 276 defer teardown() 277 278 mux.HandleFunc("/repos/o/r/actions/runs/3434/rerun", func(w http.ResponseWriter, r *http.Request) { 279 testMethod(t, r, "POST") 280 w.WriteHeader(http.StatusCreated) 281 }) 282 283 ctx := context.Background() 284 resp, err := client.Actions.RerunWorkflowByID(ctx, "o", "r", 3434) 285 if err != nil { 286 t.Errorf("Actions.RerunWorkflowByID returned error: %v", err) 287 } 288 if resp.StatusCode != http.StatusCreated { 289 t.Errorf("Actions.RerunWorkflowRunByID returned status: %d, want %d", resp.StatusCode, http.StatusCreated) 290 } 291 292 const methodName = "RerunWorkflowByID" 293 testBadOptions(t, methodName, func() (err error) { 294 _, err = client.Actions.RerunWorkflowByID(ctx, "\n", "\n", 3434) 295 return err 296 }) 297 298 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 299 return client.Actions.RerunWorkflowByID(ctx, "o", "r", 3434) 300 }) 301 } 302 303 func TestActionsService_RerunFailedJobsByID(t *testing.T) { 304 client, mux, _, teardown := setup() 305 defer teardown() 306 307 mux.HandleFunc("/repos/o/r/actions/runs/3434/rerun-failed-jobs", func(w http.ResponseWriter, r *http.Request) { 308 testMethod(t, r, "POST") 309 w.WriteHeader(http.StatusCreated) 310 }) 311 312 ctx := context.Background() 313 resp, err := client.Actions.RerunFailedJobsByID(ctx, "o", "r", 3434) 314 if err != nil { 315 t.Errorf("Actions.RerunFailedJobsByID returned error: %v", err) 316 } 317 if resp.StatusCode != http.StatusCreated { 318 t.Errorf("Actions.RerunFailedJobsByID returned status: %d, want %d", resp.StatusCode, http.StatusCreated) 319 } 320 321 const methodName = "RerunFailedJobsByID" 322 testBadOptions(t, methodName, func() (err error) { 323 _, err = client.Actions.RerunFailedJobsByID(ctx, "\n", "\n", 3434) 324 return err 325 }) 326 327 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 328 return client.Actions.RerunFailedJobsByID(ctx, "o", "r", 3434) 329 }) 330 } 331 332 func TestActionsService_RerunJobByID(t *testing.T) { 333 client, mux, _, teardown := setup() 334 defer teardown() 335 336 mux.HandleFunc("/repos/o/r/actions/jobs/3434/rerun", func(w http.ResponseWriter, r *http.Request) { 337 testMethod(t, r, "POST") 338 w.WriteHeader(http.StatusCreated) 339 }) 340 341 ctx := context.Background() 342 resp, err := client.Actions.RerunJobByID(ctx, "o", "r", 3434) 343 if err != nil { 344 t.Errorf("Actions.RerunJobByID returned error: %v", err) 345 } 346 if resp.StatusCode != http.StatusCreated { 347 t.Errorf("Actions.RerunJobByID returned status: %d, want %d", resp.StatusCode, http.StatusCreated) 348 } 349 350 const methodName = "RerunJobByID" 351 testBadOptions(t, methodName, func() (err error) { 352 _, err = client.Actions.RerunJobByID(ctx, "\n", "\n", 3434) 353 return err 354 }) 355 356 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 357 return client.Actions.RerunJobByID(ctx, "o", "r", 3434) 358 }) 359 } 360 361 func TestActionsService_CancelWorkflowRunByID(t *testing.T) { 362 client, mux, _, teardown := setup() 363 defer teardown() 364 365 mux.HandleFunc("/repos/o/r/actions/runs/3434/cancel", func(w http.ResponseWriter, r *http.Request) { 366 testMethod(t, r, "POST") 367 w.WriteHeader(http.StatusAccepted) 368 }) 369 370 ctx := context.Background() 371 resp, err := client.Actions.CancelWorkflowRunByID(ctx, "o", "r", 3434) 372 if _, ok := err.(*AcceptedError); !ok { 373 t.Errorf("Actions.CancelWorkflowRunByID returned error: %v (want AcceptedError)", err) 374 } 375 if resp.StatusCode != http.StatusAccepted { 376 t.Errorf("Actions.CancelWorkflowRunByID returned status: %d, want %d", resp.StatusCode, http.StatusAccepted) 377 } 378 379 const methodName = "CancelWorkflowRunByID" 380 testBadOptions(t, methodName, func() (err error) { 381 _, err = client.Actions.CancelWorkflowRunByID(ctx, "\n", "\n", 3434) 382 return err 383 }) 384 385 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 386 return client.Actions.CancelWorkflowRunByID(ctx, "o", "r", 3434) 387 }) 388 } 389 390 func TestActionsService_GetWorkflowRunLogs(t *testing.T) { 391 client, mux, _, teardown := setup() 392 defer teardown() 393 394 mux.HandleFunc("/repos/o/r/actions/runs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { 395 testMethod(t, r, "GET") 396 http.Redirect(w, r, "http://github.com/a", http.StatusFound) 397 }) 398 399 ctx := context.Background() 400 url, resp, err := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 1) 401 if err != nil { 402 t.Errorf("Actions.GetWorkflowRunLogs returned error: %v", err) 403 } 404 if resp.StatusCode != http.StatusFound { 405 t.Errorf("Actions.GetWorkflowRunLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) 406 } 407 want := "http://github.com/a" 408 if url.String() != want { 409 t.Errorf("Actions.GetWorkflowRunLogs returned %+v, want %+v", url.String(), want) 410 } 411 412 const methodName = "GetWorkflowRunLogs" 413 testBadOptions(t, methodName, func() (err error) { 414 _, _, err = client.Actions.GetWorkflowRunLogs(ctx, "\n", "\n", 399444496, 1) 415 return err 416 }) 417 } 418 419 func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_dontFollowRedirects(t *testing.T) { 420 client, mux, _, teardown := setup() 421 defer teardown() 422 423 mux.HandleFunc("/repos/o/r/actions/runs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { 424 testMethod(t, r, "GET") 425 http.Redirect(w, r, "http://github.com/a", http.StatusMovedPermanently) 426 }) 427 428 ctx := context.Background() 429 _, resp, _ := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 0) 430 if resp.StatusCode != http.StatusMovedPermanently { 431 t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently) 432 } 433 } 434 435 func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_followRedirects(t *testing.T) { 436 client, mux, serverURL, teardown := setup() 437 defer teardown() 438 439 // Mock a redirect link, which leads to an archive link 440 mux.HandleFunc("/repos/o/r/actions/runs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { 441 testMethod(t, r, "GET") 442 redirectURL, _ := url.Parse(serverURL + baseURLPath + "/redirect") 443 http.Redirect(w, r, redirectURL.String(), http.StatusMovedPermanently) 444 }) 445 446 mux.HandleFunc("/redirect", func(w http.ResponseWriter, r *http.Request) { 447 testMethod(t, r, "GET") 448 http.Redirect(w, r, "http://github.com/a", http.StatusFound) 449 }) 450 451 ctx := context.Background() 452 url, resp, err := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 1) 453 if err != nil { 454 t.Errorf("Actions.GetWorkflowJobLogs returned error: %v", err) 455 } 456 457 if resp.StatusCode != http.StatusFound { 458 t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) 459 } 460 461 want := "http://github.com/a" 462 if url.String() != want { 463 t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url.String(), want) 464 } 465 466 const methodName = "GetWorkflowRunLogs" 467 testBadOptions(t, methodName, func() (err error) { 468 _, _, err = client.Actions.GetWorkflowRunLogs(ctx, "\n", "\n", 399444496, 1) 469 return err 470 }) 471 } 472 473 func TestActionService_ListRepositoryWorkflowRuns(t *testing.T) { 474 client, mux, _, teardown := setup() 475 defer teardown() 476 477 mux.HandleFunc("/repos/o/r/actions/runs", func(w http.ResponseWriter, r *http.Request) { 478 testMethod(t, r, "GET") 479 testFormValues(t, r, values{"per_page": "2", "page": "2"}) 480 fmt.Fprint(w, `{"total_count":2, 481 "workflow_runs":[ 482 {"id":298499444,"run_number":301,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"}, 483 {"id":298499445,"run_number":302,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"}]}`) 484 }) 485 486 opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} 487 ctx := context.Background() 488 runs, _, err := client.Actions.ListRepositoryWorkflowRuns(ctx, "o", "r", opts) 489 if err != nil { 490 t.Errorf("Actions.ListRepositoryWorkflowRuns returned error: %v", err) 491 } 492 493 expected := &WorkflowRuns{ 494 TotalCount: Int(2), 495 WorkflowRuns: []*WorkflowRun{ 496 {ID: Int64(298499444), RunNumber: Int(301), CreatedAt: &Timestamp{time.Date(2020, time.April, 11, 11, 14, 54, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.April, 11, 11, 14, 54, 0, time.UTC)}}, 497 {ID: Int64(298499445), RunNumber: Int(302), CreatedAt: &Timestamp{time.Date(2020, time.April, 11, 11, 14, 54, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.April, 11, 11, 14, 54, 0, time.UTC)}}, 498 }, 499 } 500 501 if !cmp.Equal(runs, expected) { 502 t.Errorf("Actions.ListRepositoryWorkflowRuns returned %+v, want %+v", runs, expected) 503 } 504 505 const methodName = "ListRepositoryWorkflowRuns" 506 testBadOptions(t, methodName, func() (err error) { 507 _, _, err = client.Actions.ListRepositoryWorkflowRuns(ctx, "\n", "\n", opts) 508 509 return err 510 }) 511 512 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 513 got, resp, err := client.Actions.ListRepositoryWorkflowRuns(ctx, "o", "r", opts) 514 515 if got != nil { 516 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 517 } 518 return resp, err 519 }) 520 } 521 522 func TestActionService_DeleteWorkflowRun(t *testing.T) { 523 client, mux, _, teardown := setup() 524 defer teardown() 525 526 mux.HandleFunc("/repos/o/r/actions/runs/399444496", func(w http.ResponseWriter, r *http.Request) { 527 testMethod(t, r, "DELETE") 528 529 w.WriteHeader(http.StatusNoContent) 530 }) 531 532 ctx := context.Background() 533 if _, err := client.Actions.DeleteWorkflowRun(ctx, "o", "r", 399444496); err != nil { 534 t.Errorf("DeleteWorkflowRun returned error: %v", err) 535 } 536 537 const methodName = "DeleteWorkflowRun" 538 testBadOptions(t, methodName, func() (err error) { 539 _, err = client.Actions.DeleteWorkflowRun(ctx, "\n", "\n", 399444496) 540 return err 541 }) 542 543 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 544 return client.Actions.DeleteWorkflowRun(ctx, "o", "r", 399444496) 545 }) 546 } 547 548 func TestActionService_DeleteWorkflowRunLogs(t *testing.T) { 549 client, mux, _, teardown := setup() 550 defer teardown() 551 552 mux.HandleFunc("/repos/o/r/actions/runs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { 553 testMethod(t, r, "DELETE") 554 555 w.WriteHeader(http.StatusNoContent) 556 }) 557 558 ctx := context.Background() 559 if _, err := client.Actions.DeleteWorkflowRunLogs(ctx, "o", "r", 399444496); err != nil { 560 t.Errorf("DeleteWorkflowRunLogs returned error: %v", err) 561 } 562 563 const methodName = "DeleteWorkflowRunLogs" 564 testBadOptions(t, methodName, func() (err error) { 565 _, err = client.Actions.DeleteWorkflowRunLogs(ctx, "\n", "\n", 399444496) 566 return err 567 }) 568 569 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 570 return client.Actions.DeleteWorkflowRunLogs(ctx, "o", "r", 399444496) 571 }) 572 } 573 574 func TestActionsService_GetWorkflowRunUsageByID(t *testing.T) { 575 client, mux, _, teardown := setup() 576 defer teardown() 577 578 mux.HandleFunc("/repos/o/r/actions/runs/29679449/timing", func(w http.ResponseWriter, r *http.Request) { 579 testMethod(t, r, "GET") 580 fmt.Fprint(w, `{"billable":{"UBUNTU":{"total_ms":180000,"jobs":1,"job_runs":[{"job_id":1,"duration_ms":60000}]},"MACOS":{"total_ms":240000,"jobs":2,"job_runs":[{"job_id":2,"duration_ms":30000},{"job_id":3,"duration_ms":10000}]},"WINDOWS":{"total_ms":300000,"jobs":2}},"run_duration_ms":500000}`) 581 }) 582 583 ctx := context.Background() 584 workflowRunUsage, _, err := client.Actions.GetWorkflowRunUsageByID(ctx, "o", "r", 29679449) 585 if err != nil { 586 t.Errorf("Actions.GetWorkflowRunUsageByID returned error: %v", err) 587 } 588 589 want := &WorkflowRunUsage{ 590 Billable: &WorkflowRunBillMap{ 591 "UBUNTU": &WorkflowRunBill{ 592 TotalMS: Int64(180000), 593 Jobs: Int(1), 594 JobRuns: []*WorkflowRunJobRun{ 595 { 596 JobID: Int(1), 597 DurationMS: Int64(60000), 598 }, 599 }, 600 }, 601 "MACOS": &WorkflowRunBill{ 602 TotalMS: Int64(240000), 603 Jobs: Int(2), 604 JobRuns: []*WorkflowRunJobRun{ 605 { 606 JobID: Int(2), 607 DurationMS: Int64(30000), 608 }, 609 { 610 JobID: Int(3), 611 DurationMS: Int64(10000), 612 }, 613 }, 614 }, 615 "WINDOWS": &WorkflowRunBill{ 616 TotalMS: Int64(300000), 617 Jobs: Int(2), 618 }, 619 }, 620 RunDurationMS: Int64(500000), 621 } 622 623 if !cmp.Equal(workflowRunUsage, want) { 624 t.Errorf("Actions.GetWorkflowRunUsageByID returned %+v, want %+v", workflowRunUsage, want) 625 } 626 627 const methodName = "GetWorkflowRunUsageByID" 628 testBadOptions(t, methodName, func() (err error) { 629 _, _, err = client.Actions.GetWorkflowRunUsageByID(ctx, "\n", "\n", 29679449) 630 return err 631 }) 632 633 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 634 got, resp, err := client.Actions.GetWorkflowRunUsageByID(ctx, "o", "r", 29679449) 635 if got != nil { 636 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 637 } 638 return resp, err 639 }) 640 } 641 642 func TestWorkflowRun_Marshal(t *testing.T) { 643 testJSONMarshal(t, &WorkflowRun{}, "{}") 644 645 u := &WorkflowRun{ 646 ID: Int64(1), 647 Name: String("n"), 648 NodeID: String("nid"), 649 HeadBranch: String("hb"), 650 HeadSHA: String("hs"), 651 Path: String("p"), 652 RunNumber: Int(1), 653 RunAttempt: Int(1), 654 Event: String("e"), 655 Status: String("s"), 656 Conclusion: String("c"), 657 WorkflowID: Int64(1), 658 URL: String("u"), 659 HTMLURL: String("h"), 660 PullRequests: []*PullRequest{ 661 { 662 URL: String("u"), 663 ID: Int64(1), 664 Number: Int(1), 665 Head: &PullRequestBranch{ 666 Ref: String("r"), 667 SHA: String("s"), 668 Repo: &Repository{ 669 ID: Int64(1), 670 URL: String("s"), 671 Name: String("n"), 672 }, 673 }, 674 Base: &PullRequestBranch{ 675 Ref: String("r"), 676 SHA: String("s"), 677 Repo: &Repository{ 678 ID: Int64(1), 679 URL: String("u"), 680 Name: String("n"), 681 }, 682 }, 683 }, 684 }, 685 CreatedAt: &Timestamp{referenceTime}, 686 UpdatedAt: &Timestamp{referenceTime}, 687 RunStartedAt: &Timestamp{referenceTime}, 688 JobsURL: String("j"), 689 LogsURL: String("l"), 690 CheckSuiteURL: String("c"), 691 ArtifactsURL: String("a"), 692 CancelURL: String("c"), 693 RerunURL: String("r"), 694 PreviousAttemptURL: String("p"), 695 HeadCommit: &HeadCommit{ 696 Message: String("m"), 697 Author: &CommitAuthor{ 698 Name: String("n"), 699 Email: String("e"), 700 Login: String("l"), 701 }, 702 URL: String("u"), 703 Distinct: Bool(false), 704 SHA: String("s"), 705 ID: String("i"), 706 TreeID: String("tid"), 707 Timestamp: &Timestamp{referenceTime}, 708 Committer: &CommitAuthor{ 709 Name: String("n"), 710 Email: String("e"), 711 Login: String("l"), 712 }, 713 }, 714 WorkflowURL: String("w"), 715 Repository: &Repository{ 716 ID: Int64(1), 717 URL: String("u"), 718 Name: String("n"), 719 }, 720 HeadRepository: &Repository{ 721 ID: Int64(1), 722 URL: String("u"), 723 Name: String("n"), 724 }, 725 Actor: &User{ 726 Login: String("l"), 727 ID: Int64(1), 728 AvatarURL: String("a"), 729 GravatarID: String("g"), 730 Name: String("n"), 731 Company: String("c"), 732 Blog: String("b"), 733 Location: String("l"), 734 Email: String("e"), 735 Hireable: Bool(true), 736 Bio: String("b"), 737 TwitterUsername: String("t"), 738 PublicRepos: Int(1), 739 Followers: Int(1), 740 Following: Int(1), 741 CreatedAt: &Timestamp{referenceTime}, 742 SuspendedAt: &Timestamp{referenceTime}, 743 URL: String("u"), 744 }, 745 TriggeringActor: &User{ 746 Login: String("l2"), 747 ID: Int64(2), 748 AvatarURL: String("a2"), 749 GravatarID: String("g2"), 750 Name: String("n2"), 751 Company: String("c2"), 752 Blog: String("b2"), 753 Location: String("l2"), 754 Email: String("e2"), 755 Hireable: Bool(false), 756 Bio: String("b2"), 757 TwitterUsername: String("t2"), 758 PublicRepos: Int(2), 759 Followers: Int(2), 760 Following: Int(2), 761 CreatedAt: &Timestamp{referenceTime}, 762 SuspendedAt: &Timestamp{referenceTime}, 763 URL: String("u2"), 764 }, 765 ReferencedWorkflows: []*ReferencedWorkflow{ 766 { 767 Path: String("rwfp"), 768 SHA: String("rwfsha"), 769 Ref: String("rwfref"), 770 }, 771 }, 772 } 773 774 want := `{ 775 "id": 1, 776 "name": "n", 777 "node_id": "nid", 778 "head_branch": "hb", 779 "head_sha": "hs", 780 "path": "p", 781 "run_number": 1, 782 "run_attempt": 1, 783 "event": "e", 784 "status": "s", 785 "conclusion": "c", 786 "workflow_id": 1, 787 "url": "u", 788 "html_url": "h", 789 "pull_requests": [ 790 { 791 "id":1, 792 "number":1, 793 "url":"u", 794 "head":{ 795 "ref":"r", 796 "sha":"s", 797 "repo": { 798 "id":1, 799 "name":"n", 800 "url":"s" 801 } 802 }, 803 "base": { 804 "ref":"r", 805 "sha":"s", 806 "repo": { 807 "id":1, 808 "name":"n", 809 "url":"u" 810 } 811 } 812 } 813 ], 814 "created_at": ` + referenceTimeStr + `, 815 "updated_at": ` + referenceTimeStr + `, 816 "run_started_at": ` + referenceTimeStr + `, 817 "jobs_url": "j", 818 "logs_url": "l", 819 "check_suite_url": "c", 820 "artifacts_url": "a", 821 "cancel_url": "c", 822 "rerun_url": "r", 823 "previous_attempt_url": "p", 824 "head_commit": { 825 "message": "m", 826 "author": { 827 "name": "n", 828 "email": "e", 829 "username": "l" 830 }, 831 "url": "u", 832 "distinct": false, 833 "sha": "s", 834 "id": "i", 835 "tree_id": "tid", 836 "timestamp": ` + referenceTimeStr + `, 837 "committer": { 838 "name": "n", 839 "email": "e", 840 "username": "l" 841 } 842 }, 843 "workflow_url": "w", 844 "repository": { 845 "id": 1, 846 "url": "u", 847 "name": "n" 848 }, 849 "head_repository": { 850 "id": 1, 851 "url": "u", 852 "name": "n" 853 }, 854 "actor": { 855 "login": "l", 856 "id": 1, 857 "avatar_url": "a", 858 "gravatar_id": "g", 859 "name": "n", 860 "company": "c", 861 "blog": "b", 862 "location": "l", 863 "email": "e", 864 "hireable": true, 865 "bio": "b", 866 "twitter_username": "t", 867 "public_repos": 1, 868 "followers": 1, 869 "following": 1, 870 "created_at": ` + referenceTimeStr + `, 871 "suspended_at": ` + referenceTimeStr + `, 872 "url": "u" 873 }, 874 "triggering_actor": { 875 "login": "l2", 876 "id": 2, 877 "avatar_url": "a2", 878 "gravatar_id": "g2", 879 "name": "n2", 880 "company": "c2", 881 "blog": "b2", 882 "location": "l2", 883 "email": "e2", 884 "hireable": false, 885 "bio": "b2", 886 "twitter_username": "t2", 887 "public_repos": 2, 888 "followers": 2, 889 "following": 2, 890 "created_at": ` + referenceTimeStr + `, 891 "suspended_at": ` + referenceTimeStr + `, 892 "url": "u2" 893 }, 894 "referenced_workflows": [ 895 { 896 "path": "rwfp", 897 "sha": "rwfsha", 898 "ref": "rwfref" 899 } 900 ] 901 }` 902 903 testJSONMarshal(t, u, want) 904 } 905 906 func TestWorkflowRuns_Marshal(t *testing.T) { 907 testJSONMarshal(t, &WorkflowRuns{}, "{}") 908 909 u := &WorkflowRuns{ 910 TotalCount: Int(1), 911 WorkflowRuns: []*WorkflowRun{ 912 { 913 ID: Int64(1), 914 Name: String("n"), 915 NodeID: String("nid"), 916 HeadBranch: String("hb"), 917 HeadSHA: String("hs"), 918 RunNumber: Int(1), 919 RunAttempt: Int(1), 920 Event: String("e"), 921 Status: String("s"), 922 Conclusion: String("c"), 923 WorkflowID: Int64(1), 924 URL: String("u"), 925 HTMLURL: String("h"), 926 PullRequests: []*PullRequest{ 927 { 928 URL: String("u"), 929 ID: Int64(1), 930 Number: Int(1), 931 Head: &PullRequestBranch{ 932 Ref: String("r"), 933 SHA: String("s"), 934 Repo: &Repository{ 935 ID: Int64(1), 936 URL: String("s"), 937 Name: String("n"), 938 }, 939 }, 940 Base: &PullRequestBranch{ 941 Ref: String("r"), 942 SHA: String("s"), 943 Repo: &Repository{ 944 ID: Int64(1), 945 URL: String("u"), 946 Name: String("n"), 947 }, 948 }, 949 }, 950 }, 951 CreatedAt: &Timestamp{referenceTime}, 952 UpdatedAt: &Timestamp{referenceTime}, 953 RunStartedAt: &Timestamp{referenceTime}, 954 JobsURL: String("j"), 955 LogsURL: String("l"), 956 CheckSuiteURL: String("c"), 957 ArtifactsURL: String("a"), 958 CancelURL: String("c"), 959 RerunURL: String("r"), 960 PreviousAttemptURL: String("p"), 961 HeadCommit: &HeadCommit{ 962 Message: String("m"), 963 Author: &CommitAuthor{ 964 Name: String("n"), 965 Email: String("e"), 966 Login: String("l"), 967 }, 968 URL: String("u"), 969 Distinct: Bool(false), 970 SHA: String("s"), 971 ID: String("i"), 972 TreeID: String("tid"), 973 Timestamp: &Timestamp{referenceTime}, 974 Committer: &CommitAuthor{ 975 Name: String("n"), 976 Email: String("e"), 977 Login: String("l"), 978 }, 979 }, 980 WorkflowURL: String("w"), 981 Repository: &Repository{ 982 ID: Int64(1), 983 URL: String("u"), 984 Name: String("n"), 985 }, 986 HeadRepository: &Repository{ 987 ID: Int64(1), 988 URL: String("u"), 989 Name: String("n"), 990 }, 991 Actor: &User{ 992 Login: String("l"), 993 ID: Int64(1), 994 AvatarURL: String("a"), 995 GravatarID: String("g"), 996 Name: String("n"), 997 Company: String("c"), 998 Blog: String("b"), 999 Location: String("l"), 1000 Email: String("e"), 1001 Hireable: Bool(true), 1002 Bio: String("b"), 1003 TwitterUsername: String("t"), 1004 PublicRepos: Int(1), 1005 Followers: Int(1), 1006 Following: Int(1), 1007 CreatedAt: &Timestamp{referenceTime}, 1008 SuspendedAt: &Timestamp{referenceTime}, 1009 URL: String("u"), 1010 }, 1011 TriggeringActor: &User{ 1012 Login: String("l2"), 1013 ID: Int64(2), 1014 AvatarURL: String("a2"), 1015 GravatarID: String("g2"), 1016 Name: String("n2"), 1017 Company: String("c2"), 1018 Blog: String("b2"), 1019 Location: String("l2"), 1020 Email: String("e2"), 1021 Hireable: Bool(false), 1022 Bio: String("b2"), 1023 TwitterUsername: String("t2"), 1024 PublicRepos: Int(2), 1025 Followers: Int(2), 1026 Following: Int(2), 1027 CreatedAt: &Timestamp{referenceTime}, 1028 SuspendedAt: &Timestamp{referenceTime}, 1029 URL: String("u2"), 1030 }, 1031 }, 1032 }, 1033 } 1034 1035 want := `{ 1036 "total_count": 1, 1037 "workflow_runs": [ 1038 { 1039 "id": 1, 1040 "name": "n", 1041 "node_id": "nid", 1042 "head_branch": "hb", 1043 "head_sha": "hs", 1044 "run_number": 1, 1045 "run_attempt": 1, 1046 "event": "e", 1047 "status": "s", 1048 "conclusion": "c", 1049 "workflow_id": 1, 1050 "url": "u", 1051 "html_url": "h", 1052 "pull_requests": [ 1053 { 1054 "id":1, 1055 "number":1, 1056 "url":"u", 1057 "head":{ 1058 "ref":"r", 1059 "sha":"s", 1060 "repo": { 1061 "id":1, 1062 "name":"n", 1063 "url":"s" 1064 } 1065 }, 1066 "base": { 1067 "ref":"r", 1068 "sha":"s", 1069 "repo": { 1070 "id":1, 1071 "name":"n", 1072 "url":"u" 1073 } 1074 } 1075 } 1076 ], 1077 "created_at": ` + referenceTimeStr + `, 1078 "updated_at": ` + referenceTimeStr + `, 1079 "run_started_at": ` + referenceTimeStr + `, 1080 "jobs_url": "j", 1081 "logs_url": "l", 1082 "check_suite_url": "c", 1083 "artifacts_url": "a", 1084 "cancel_url": "c", 1085 "rerun_url": "r", 1086 "previous_attempt_url": "p", 1087 "head_commit": { 1088 "message": "m", 1089 "author": { 1090 "name": "n", 1091 "email": "e", 1092 "username": "l" 1093 }, 1094 "url": "u", 1095 "distinct": false, 1096 "sha": "s", 1097 "id": "i", 1098 "tree_id": "tid", 1099 "timestamp": ` + referenceTimeStr + `, 1100 "committer": { 1101 "name": "n", 1102 "email": "e", 1103 "username": "l" 1104 } 1105 }, 1106 "workflow_url": "w", 1107 "repository": { 1108 "id": 1, 1109 "url": "u", 1110 "name": "n" 1111 }, 1112 "head_repository": { 1113 "id": 1, 1114 "url": "u", 1115 "name": "n" 1116 }, 1117 "actor": { 1118 "login": "l", 1119 "id": 1, 1120 "avatar_url": "a", 1121 "gravatar_id": "g", 1122 "name": "n", 1123 "company": "c", 1124 "blog": "b", 1125 "location": "l", 1126 "email": "e", 1127 "hireable": true, 1128 "bio": "b", 1129 "twitter_username": "t", 1130 "public_repos": 1, 1131 "followers": 1, 1132 "following": 1, 1133 "created_at": ` + referenceTimeStr + `, 1134 "suspended_at": ` + referenceTimeStr + `, 1135 "url": "u" 1136 }, 1137 "triggering_actor": { 1138 "login": "l2", 1139 "id": 2, 1140 "avatar_url": "a2", 1141 "gravatar_id": "g2", 1142 "name": "n2", 1143 "company": "c2", 1144 "blog": "b2", 1145 "location": "l2", 1146 "email": "e2", 1147 "hireable": false, 1148 "bio": "b2", 1149 "twitter_username": "t2", 1150 "public_repos": 2, 1151 "followers": 2, 1152 "following": 2, 1153 "created_at": ` + referenceTimeStr + `, 1154 "suspended_at": ` + referenceTimeStr + `, 1155 "url": "u2" 1156 } 1157 } 1158 ] 1159 }` 1160 1161 testJSONMarshal(t, u, want) 1162 } 1163 1164 func TestWorkflowRunBill_Marshal(t *testing.T) { 1165 testJSONMarshal(t, &WorkflowRunBill{}, "{}") 1166 1167 u := &WorkflowRunBill{ 1168 TotalMS: Int64(1), 1169 Jobs: Int(1), 1170 } 1171 1172 want := `{ 1173 "total_ms": 1, 1174 "jobs": 1 1175 }` 1176 1177 testJSONMarshal(t, u, want) 1178 } 1179 1180 func TestWorkflowRunBillMap_Marshal(t *testing.T) { 1181 testJSONMarshal(t, &WorkflowRunBillMap{}, "{}") 1182 1183 u := &WorkflowRunBillMap{ 1184 "UBUNTU": &WorkflowRunBill{ 1185 TotalMS: Int64(1), 1186 Jobs: Int(1), 1187 }, 1188 "MACOS": &WorkflowRunBill{ 1189 TotalMS: Int64(1), 1190 Jobs: Int(1), 1191 }, 1192 "WINDOWS": &WorkflowRunBill{ 1193 TotalMS: Int64(1), 1194 Jobs: Int(1), 1195 }, 1196 } 1197 1198 want := `{ 1199 "UBUNTU": { 1200 "total_ms": 1, 1201 "jobs": 1 1202 }, 1203 "MACOS": { 1204 "total_ms": 1, 1205 "jobs": 1 1206 }, 1207 "WINDOWS": { 1208 "total_ms": 1, 1209 "jobs": 1 1210 } 1211 }` 1212 1213 testJSONMarshal(t, u, want) 1214 } 1215 1216 func TestWorkflowRunUsage_Marshal(t *testing.T) { 1217 testJSONMarshal(t, &WorkflowRunUsage{}, "{}") 1218 1219 u := &WorkflowRunUsage{ 1220 Billable: &WorkflowRunBillMap{ 1221 "UBUNTU": &WorkflowRunBill{ 1222 TotalMS: Int64(1), 1223 Jobs: Int(1), 1224 }, 1225 "MACOS": &WorkflowRunBill{ 1226 TotalMS: Int64(1), 1227 Jobs: Int(1), 1228 }, 1229 "WINDOWS": &WorkflowRunBill{ 1230 TotalMS: Int64(1), 1231 Jobs: Int(1), 1232 }, 1233 }, 1234 RunDurationMS: Int64(1), 1235 } 1236 1237 want := `{ 1238 "billable": { 1239 "UBUNTU": { 1240 "total_ms": 1, 1241 "jobs": 1 1242 }, 1243 "MACOS": { 1244 "total_ms": 1, 1245 "jobs": 1 1246 }, 1247 "WINDOWS": { 1248 "total_ms": 1, 1249 "jobs": 1 1250 } 1251 }, 1252 "run_duration_ms": 1 1253 }` 1254 1255 testJSONMarshal(t, u, want) 1256 } 1257 1258 func TestActionService_PendingDeployments(t *testing.T) { 1259 client, mux, _, teardown := setup() 1260 defer teardown() 1261 1262 input := &PendingDeploymentsRequest{EnvironmentIDs: []int64{3, 4}, State: "approved", Comment: ""} 1263 1264 mux.HandleFunc("/repos/o/r/actions/runs/399444496/pending_deployments", func(w http.ResponseWriter, r *http.Request) { 1265 v := new(PendingDeploymentsRequest) 1266 assertNilError(t, json.NewDecoder(r.Body).Decode(v)) 1267 1268 testMethod(t, r, "POST") 1269 if !cmp.Equal(v, input) { 1270 t.Errorf("Request body = %+v, want %+v", v, input) 1271 } 1272 1273 fmt.Fprint(w, `[{"id":1}, {"id":2}]`) 1274 }) 1275 1276 ctx := context.Background() 1277 deployments, _, err := client.Actions.PendingDeployments(ctx, "o", "r", 399444496, input) 1278 if err != nil { 1279 t.Errorf("Actions.PendingDeployments returned error: %v", err) 1280 } 1281 1282 want := []*Deployment{{ID: Int64(1)}, {ID: Int64(2)}} 1283 if !cmp.Equal(deployments, want) { 1284 t.Errorf("Actions.PendingDeployments returned %+v, want %+v", deployments, want) 1285 } 1286 1287 const methodName = "PendingDeployments" 1288 testBadOptions(t, methodName, func() (err error) { 1289 _, _, err = client.Actions.PendingDeployments(ctx, "\n", "\n", 399444496, input) 1290 return err 1291 }) 1292 1293 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 1294 got, resp, err := client.Actions.PendingDeployments(ctx, "o", "r", 399444496, input) 1295 if got != nil { 1296 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 1297 } 1298 return resp, err 1299 }) 1300 }