github.com/google/go-github/v68@v68.0.0/github/actions_workflows_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 "testing" 14 "time" 15 16 "github.com/google/go-cmp/cmp" 17 ) 18 19 func TestActionsService_ListWorkflows(t *testing.T) { 20 t.Parallel() 21 client, mux, _ := setup(t) 22 23 mux.HandleFunc("/repos/o/r/actions/workflows", func(w http.ResponseWriter, r *http.Request) { 24 testMethod(t, r, "GET") 25 testFormValues(t, r, values{"per_page": "2", "page": "2"}) 26 fmt.Fprint(w, `{"total_count":4,"workflows":[{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"id":72845,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) 27 }) 28 29 opts := &ListOptions{Page: 2, PerPage: 2} 30 ctx := context.Background() 31 workflows, _, err := client.Actions.ListWorkflows(ctx, "o", "r", opts) 32 if err != nil { 33 t.Errorf("Actions.ListWorkflows returned error: %v", err) 34 } 35 36 want := &Workflows{ 37 TotalCount: Ptr(4), 38 Workflows: []*Workflow{ 39 {ID: Ptr(int64(72844)), 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)}}, 40 {ID: Ptr(int64(72845)), 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 }, 42 } 43 if !cmp.Equal(workflows, want) { 44 t.Errorf("Actions.ListWorkflows returned %+v, want %+v", workflows, want) 45 } 46 47 const methodName = "ListWorkflows" 48 testBadOptions(t, methodName, func() (err error) { 49 _, _, err = client.Actions.ListWorkflows(ctx, "\n", "\n", opts) 50 return err 51 }) 52 53 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 54 got, resp, err := client.Actions.ListWorkflows(ctx, "o", "r", opts) 55 if got != nil { 56 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 57 } 58 return resp, err 59 }) 60 } 61 62 func TestActionsService_GetWorkflowByID(t *testing.T) { 63 t.Parallel() 64 client, mux, _ := setup(t) 65 66 mux.HandleFunc("/repos/o/r/actions/workflows/72844", func(w http.ResponseWriter, r *http.Request) { 67 testMethod(t, r, "GET") 68 fmt.Fprint(w, `{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) 69 }) 70 71 ctx := context.Background() 72 workflow, _, err := client.Actions.GetWorkflowByID(ctx, "o", "r", 72844) 73 if err != nil { 74 t.Errorf("Actions.GetWorkflowByID returned error: %v", err) 75 } 76 77 want := &Workflow{ 78 ID: Ptr(int64(72844)), 79 CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, 80 UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, 81 } 82 if !cmp.Equal(workflow, want) { 83 t.Errorf("Actions.GetWorkflowByID returned %+v, want %+v", workflow, want) 84 } 85 86 const methodName = "GetWorkflowByID" 87 testBadOptions(t, methodName, func() (err error) { 88 _, _, err = client.Actions.GetWorkflowByID(ctx, "\n", "\n", -72844) 89 return err 90 }) 91 92 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 93 got, resp, err := client.Actions.GetWorkflowByID(ctx, "o", "r", 72844) 94 if got != nil { 95 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 96 } 97 return resp, err 98 }) 99 } 100 101 func TestActionsService_GetWorkflowByFileName(t *testing.T) { 102 t.Parallel() 103 client, mux, _ := setup(t) 104 105 mux.HandleFunc("/repos/o/r/actions/workflows/main.yml", func(w http.ResponseWriter, r *http.Request) { 106 testMethod(t, r, "GET") 107 fmt.Fprint(w, `{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) 108 }) 109 110 ctx := context.Background() 111 workflow, _, err := client.Actions.GetWorkflowByFileName(ctx, "o", "r", "main.yml") 112 if err != nil { 113 t.Errorf("Actions.GetWorkflowByFileName returned error: %v", err) 114 } 115 116 want := &Workflow{ 117 ID: Ptr(int64(72844)), 118 CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, 119 UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, 120 } 121 if !cmp.Equal(workflow, want) { 122 t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", workflow, want) 123 } 124 125 const methodName = "GetWorkflowByFileName" 126 testBadOptions(t, methodName, func() (err error) { 127 _, _, err = client.Actions.GetWorkflowByFileName(ctx, "\n", "\n", "\n") 128 return err 129 }) 130 131 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 132 got, resp, err := client.Actions.GetWorkflowByFileName(ctx, "o", "r", "main.yml") 133 if got != nil { 134 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 135 } 136 return resp, err 137 }) 138 } 139 140 func TestActionsService_GetWorkflowUsageByID(t *testing.T) { 141 t.Parallel() 142 client, mux, _ := setup(t) 143 144 mux.HandleFunc("/repos/o/r/actions/workflows/72844/timing", func(w http.ResponseWriter, r *http.Request) { 145 testMethod(t, r, "GET") 146 fmt.Fprint(w, `{"billable":{"UBUNTU":{"total_ms":180000},"MACOS":{"total_ms":240000},"WINDOWS":{"total_ms":300000}}}`) 147 }) 148 149 ctx := context.Background() 150 workflowUsage, _, err := client.Actions.GetWorkflowUsageByID(ctx, "o", "r", 72844) 151 if err != nil { 152 t.Errorf("Actions.GetWorkflowUsageByID returned error: %v", err) 153 } 154 155 want := &WorkflowUsage{ 156 Billable: &WorkflowBillMap{ 157 "UBUNTU": &WorkflowBill{ 158 TotalMS: Ptr(int64(180000)), 159 }, 160 "MACOS": &WorkflowBill{ 161 TotalMS: Ptr(int64(240000)), 162 }, 163 "WINDOWS": &WorkflowBill{ 164 TotalMS: Ptr(int64(300000)), 165 }, 166 }, 167 } 168 if !cmp.Equal(workflowUsage, want) { 169 t.Errorf("Actions.GetWorkflowUsageByID returned %+v, want %+v", workflowUsage, want) 170 } 171 172 const methodName = "GetWorkflowUsageByID" 173 testBadOptions(t, methodName, func() (err error) { 174 _, _, err = client.Actions.GetWorkflowUsageByID(ctx, "\n", "\n", -72844) 175 return err 176 }) 177 178 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 179 got, resp, err := client.Actions.GetWorkflowUsageByID(ctx, "o", "r", 72844) 180 if got != nil { 181 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 182 } 183 return resp, err 184 }) 185 } 186 187 func TestActionsService_GetWorkflowUsageByFileName(t *testing.T) { 188 t.Parallel() 189 client, mux, _ := setup(t) 190 191 mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/timing", func(w http.ResponseWriter, r *http.Request) { 192 testMethod(t, r, "GET") 193 fmt.Fprint(w, `{"billable":{"UBUNTU":{"total_ms":180000},"MACOS":{"total_ms":240000},"WINDOWS":{"total_ms":300000}}}`) 194 }) 195 196 ctx := context.Background() 197 workflowUsage, _, err := client.Actions.GetWorkflowUsageByFileName(ctx, "o", "r", "main.yml") 198 if err != nil { 199 t.Errorf("Actions.GetWorkflowUsageByFileName returned error: %v", err) 200 } 201 202 want := &WorkflowUsage{ 203 Billable: &WorkflowBillMap{ 204 "UBUNTU": &WorkflowBill{ 205 TotalMS: Ptr(int64(180000)), 206 }, 207 "MACOS": &WorkflowBill{ 208 TotalMS: Ptr(int64(240000)), 209 }, 210 "WINDOWS": &WorkflowBill{ 211 TotalMS: Ptr(int64(300000)), 212 }, 213 }, 214 } 215 if !cmp.Equal(workflowUsage, want) { 216 t.Errorf("Actions.GetWorkflowUsageByFileName returned %+v, want %+v", workflowUsage, want) 217 } 218 219 const methodName = "GetWorkflowUsageByFileName" 220 testBadOptions(t, methodName, func() (err error) { 221 _, _, err = client.Actions.GetWorkflowUsageByFileName(ctx, "\n", "\n", "\n") 222 return err 223 }) 224 225 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 226 got, resp, err := client.Actions.GetWorkflowUsageByFileName(ctx, "o", "r", "main.yml") 227 if got != nil { 228 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) 229 } 230 return resp, err 231 }) 232 } 233 234 func TestActionsService_CreateWorkflowDispatchEventByID(t *testing.T) { 235 t.Parallel() 236 client, mux, _ := setup(t) 237 238 event := CreateWorkflowDispatchEventRequest{ 239 Ref: "d4cfb6e7", 240 Inputs: map[string]interface{}{ 241 "key": "value", 242 }, 243 } 244 mux.HandleFunc("/repos/o/r/actions/workflows/72844/dispatches", func(w http.ResponseWriter, r *http.Request) { 245 var v CreateWorkflowDispatchEventRequest 246 assertNilError(t, json.NewDecoder(r.Body).Decode(&v)) 247 248 testMethod(t, r, "POST") 249 if !cmp.Equal(v, event) { 250 t.Errorf("Request body = %+v, want %+v", v, event) 251 } 252 }) 253 254 ctx := context.Background() 255 _, err := client.Actions.CreateWorkflowDispatchEventByID(ctx, "o", "r", 72844, event) 256 if err != nil { 257 t.Errorf("Actions.CreateWorkflowDispatchEventByID returned error: %v", err) 258 } 259 260 // Test s.client.NewRequest failure 261 client.BaseURL.Path = "" 262 _, err = client.Actions.CreateWorkflowDispatchEventByID(ctx, "o", "r", 72844, event) 263 if err == nil { 264 t.Error("client.BaseURL.Path='' CreateWorkflowDispatchEventByID err = nil, want error") 265 } 266 267 const methodName = "CreateWorkflowDispatchEventByID" 268 testBadOptions(t, methodName, func() (err error) { 269 _, err = client.Actions.CreateWorkflowDispatchEventByID(ctx, "o", "r", 72844, event) 270 return err 271 }) 272 273 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 274 return client.Actions.CreateWorkflowDispatchEventByID(ctx, "o", "r", 72844, event) 275 }) 276 } 277 278 func TestActionsService_CreateWorkflowDispatchEventByFileName(t *testing.T) { 279 t.Parallel() 280 client, mux, _ := setup(t) 281 282 event := CreateWorkflowDispatchEventRequest{ 283 Ref: "d4cfb6e7", 284 Inputs: map[string]interface{}{ 285 "key": "value", 286 }, 287 } 288 mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/dispatches", func(w http.ResponseWriter, r *http.Request) { 289 var v CreateWorkflowDispatchEventRequest 290 assertNilError(t, json.NewDecoder(r.Body).Decode(&v)) 291 292 testMethod(t, r, "POST") 293 if !cmp.Equal(v, event) { 294 t.Errorf("Request body = %+v, want %+v", v, event) 295 } 296 }) 297 298 ctx := context.Background() 299 _, err := client.Actions.CreateWorkflowDispatchEventByFileName(ctx, "o", "r", "main.yml", event) 300 if err != nil { 301 t.Errorf("Actions.CreateWorkflowDispatchEventByFileName returned error: %v", err) 302 } 303 304 // Test s.client.NewRequest failure 305 client.BaseURL.Path = "" 306 _, err = client.Actions.CreateWorkflowDispatchEventByFileName(ctx, "o", "r", "main.yml", event) 307 if err == nil { 308 t.Error("client.BaseURL.Path='' CreateWorkflowDispatchEventByFileName err = nil, want error") 309 } 310 311 const methodName = "CreateWorkflowDispatchEventByFileName" 312 testBadOptions(t, methodName, func() (err error) { 313 _, err = client.Actions.CreateWorkflowDispatchEventByFileName(ctx, "o", "r", "main.yml", event) 314 return err 315 }) 316 317 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 318 return client.Actions.CreateWorkflowDispatchEventByFileName(ctx, "o", "r", "main.yml", event) 319 }) 320 } 321 322 func TestActionsService_EnableWorkflowByID(t *testing.T) { 323 t.Parallel() 324 client, mux, _ := setup(t) 325 326 mux.HandleFunc("/repos/o/r/actions/workflows/72844/enable", func(w http.ResponseWriter, r *http.Request) { 327 testMethod(t, r, "PUT") 328 if r.Body != http.NoBody { 329 t.Errorf("Request body = %+v, want %+v", r.Body, http.NoBody) 330 } 331 }) 332 333 ctx := context.Background() 334 _, err := client.Actions.EnableWorkflowByID(ctx, "o", "r", 72844) 335 if err != nil { 336 t.Errorf("Actions.EnableWorkflowByID returned error: %v", err) 337 } 338 339 // Test s.client.NewRequest failure 340 client.BaseURL.Path = "" 341 _, err = client.Actions.EnableWorkflowByID(ctx, "o", "r", 72844) 342 if err == nil { 343 t.Error("client.BaseURL.Path='' EnableWorkflowByID err = nil, want error") 344 } 345 346 const methodName = "EnableWorkflowByID" 347 testBadOptions(t, methodName, func() (err error) { 348 _, err = client.Actions.EnableWorkflowByID(ctx, "o", "r", 72844) 349 return err 350 }) 351 352 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 353 return client.Actions.EnableWorkflowByID(ctx, "o", "r", 72844) 354 }) 355 } 356 357 func TestActionsService_EnableWorkflowByFilename(t *testing.T) { 358 t.Parallel() 359 client, mux, _ := setup(t) 360 361 mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/enable", func(w http.ResponseWriter, r *http.Request) { 362 testMethod(t, r, "PUT") 363 if r.Body != http.NoBody { 364 t.Errorf("Request body = %+v, want %+v", r.Body, http.NoBody) 365 } 366 }) 367 368 ctx := context.Background() 369 _, err := client.Actions.EnableWorkflowByFileName(ctx, "o", "r", "main.yml") 370 if err != nil { 371 t.Errorf("Actions.EnableWorkflowByFilename returned error: %v", err) 372 } 373 374 // Test s.client.NewRequest failure 375 client.BaseURL.Path = "" 376 _, err = client.Actions.EnableWorkflowByFileName(ctx, "o", "r", "main.yml") 377 if err == nil { 378 t.Error("client.BaseURL.Path='' EnableWorkflowByFilename err = nil, want error") 379 } 380 381 const methodName = "EnableWorkflowByFileName" 382 testBadOptions(t, methodName, func() (err error) { 383 _, err = client.Actions.EnableWorkflowByFileName(ctx, "o", "r", "main.yml") 384 return err 385 }) 386 387 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 388 return client.Actions.EnableWorkflowByFileName(ctx, "o", "r", "main.yml") 389 }) 390 } 391 392 func TestActionsService_DisableWorkflowByID(t *testing.T) { 393 t.Parallel() 394 client, mux, _ := setup(t) 395 396 mux.HandleFunc("/repos/o/r/actions/workflows/72844/disable", func(w http.ResponseWriter, r *http.Request) { 397 testMethod(t, r, "PUT") 398 if r.Body != http.NoBody { 399 t.Errorf("Request body = %+v, want %+v", r.Body, http.NoBody) 400 } 401 }) 402 403 ctx := context.Background() 404 _, err := client.Actions.DisableWorkflowByID(ctx, "o", "r", 72844) 405 if err != nil { 406 t.Errorf("Actions.DisableWorkflowByID returned error: %v", err) 407 } 408 409 // Test s.client.NewRequest failure 410 client.BaseURL.Path = "" 411 _, err = client.Actions.DisableWorkflowByID(ctx, "o", "r", 72844) 412 if err == nil { 413 t.Error("client.BaseURL.Path='' DisableWorkflowByID err = nil, want error") 414 } 415 416 const methodName = "DisableWorkflowByID" 417 testBadOptions(t, methodName, func() (err error) { 418 _, err = client.Actions.DisableWorkflowByID(ctx, "o", "r", 72844) 419 return err 420 }) 421 422 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 423 return client.Actions.DisableWorkflowByID(ctx, "o", "r", 72844) 424 }) 425 } 426 427 func TestActionsService_DisableWorkflowByFileName(t *testing.T) { 428 t.Parallel() 429 client, mux, _ := setup(t) 430 431 mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/disable", func(w http.ResponseWriter, r *http.Request) { 432 testMethod(t, r, "PUT") 433 if r.Body != http.NoBody { 434 t.Errorf("Request body = %+v, want %+v", r.Body, http.NoBody) 435 } 436 }) 437 438 ctx := context.Background() 439 _, err := client.Actions.DisableWorkflowByFileName(ctx, "o", "r", "main.yml") 440 if err != nil { 441 t.Errorf("Actions.DisableWorkflowByFileName returned error: %v", err) 442 } 443 444 // Test s.client.NewRequest failure 445 client.BaseURL.Path = "" 446 _, err = client.Actions.DisableWorkflowByFileName(ctx, "o", "r", "main.yml") 447 if err == nil { 448 t.Error("client.BaseURL.Path='' DisableWorkflowByFileName err = nil, want error") 449 } 450 451 const methodName = "DisableWorkflowByFileName" 452 testBadOptions(t, methodName, func() (err error) { 453 _, err = client.Actions.DisableWorkflowByFileName(ctx, "o", "r", "main.yml") 454 return err 455 }) 456 457 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { 458 return client.Actions.DisableWorkflowByFileName(ctx, "o", "r", "main.yml") 459 }) 460 } 461 462 func TestWorkflow_Marshal(t *testing.T) { 463 t.Parallel() 464 testJSONMarshal(t, &Workflow{}, "{}") 465 466 u := &Workflow{ 467 ID: Ptr(int64(1)), 468 NodeID: Ptr("nid"), 469 Name: Ptr("n"), 470 Path: Ptr("p"), 471 State: Ptr("s"), 472 CreatedAt: &Timestamp{referenceTime}, 473 UpdatedAt: &Timestamp{referenceTime}, 474 URL: Ptr("u"), 475 HTMLURL: Ptr("h"), 476 BadgeURL: Ptr("b"), 477 } 478 479 want := `{ 480 "id": 1, 481 "node_id": "nid", 482 "name": "n", 483 "path": "p", 484 "state": "s", 485 "created_at": ` + referenceTimeStr + `, 486 "updated_at": ` + referenceTimeStr + `, 487 "url": "u", 488 "html_url": "h", 489 "badge_url": "b" 490 }` 491 492 testJSONMarshal(t, u, want) 493 } 494 495 func TestWorkflows_Marshal(t *testing.T) { 496 t.Parallel() 497 testJSONMarshal(t, &Workflows{}, "{}") 498 499 u := &Workflows{ 500 TotalCount: Ptr(1), 501 Workflows: []*Workflow{ 502 { 503 ID: Ptr(int64(1)), 504 NodeID: Ptr("nid"), 505 Name: Ptr("n"), 506 Path: Ptr("p"), 507 State: Ptr("s"), 508 CreatedAt: &Timestamp{referenceTime}, 509 UpdatedAt: &Timestamp{referenceTime}, 510 URL: Ptr("u"), 511 HTMLURL: Ptr("h"), 512 BadgeURL: Ptr("b"), 513 }, 514 }, 515 } 516 517 want := `{ 518 "total_count": 1, 519 "workflows": [{ 520 "id": 1, 521 "node_id": "nid", 522 "name": "n", 523 "path": "p", 524 "state": "s", 525 "created_at": ` + referenceTimeStr + `, 526 "updated_at": ` + referenceTimeStr + `, 527 "url": "u", 528 "html_url": "h", 529 "badge_url": "b" 530 }] 531 }` 532 533 testJSONMarshal(t, u, want) 534 } 535 536 func TestWorkflowBill_Marshal(t *testing.T) { 537 t.Parallel() 538 testJSONMarshal(t, &WorkflowBill{}, "{}") 539 540 u := &WorkflowBill{ 541 TotalMS: Ptr(int64(1)), 542 } 543 544 want := `{ 545 "total_ms": 1 546 }` 547 548 testJSONMarshal(t, u, want) 549 } 550 551 func TestWorkflowBillMap_Marshal(t *testing.T) { 552 t.Parallel() 553 testJSONMarshal(t, &WorkflowBillMap{}, "{}") 554 555 u := &WorkflowBillMap{ 556 "UBUNTU": &WorkflowBill{ 557 TotalMS: Ptr(int64(1)), 558 }, 559 "MACOS": &WorkflowBill{ 560 TotalMS: Ptr(int64(1)), 561 }, 562 "WINDOWS": &WorkflowBill{ 563 TotalMS: Ptr(int64(1)), 564 }, 565 } 566 567 want := `{ 568 "UBUNTU": { 569 "total_ms": 1 570 }, 571 "MACOS": { 572 "total_ms": 1 573 }, 574 "WINDOWS": { 575 "total_ms": 1 576 } 577 }` 578 579 testJSONMarshal(t, u, want) 580 } 581 582 func TestWorkflowUsage_Marshal(t *testing.T) { 583 t.Parallel() 584 testJSONMarshal(t, &WorkflowUsage{}, "{}") 585 586 u := &WorkflowUsage{ 587 Billable: &WorkflowBillMap{ 588 "UBUNTU": &WorkflowBill{ 589 TotalMS: Ptr(int64(1)), 590 }, 591 "MACOS": &WorkflowBill{ 592 TotalMS: Ptr(int64(1)), 593 }, 594 "WINDOWS": &WorkflowBill{ 595 TotalMS: Ptr(int64(1)), 596 }, 597 }, 598 } 599 600 want := `{ 601 "billable": { 602 "UBUNTU": { 603 "total_ms": 1 604 }, 605 "MACOS": { 606 "total_ms": 1 607 }, 608 "WINDOWS": { 609 "total_ms": 1 610 } 611 } 612 }` 613 614 testJSONMarshal(t, u, want) 615 } 616 617 func TestCreateWorkflowDispatchEventRequest_Marshal(t *testing.T) { 618 t.Parallel() 619 testJSONMarshal(t, &CreateWorkflowDispatchEventRequest{}, "{}") 620 621 inputs := make(map[string]interface{}, 0) 622 inputs["key"] = "value" 623 624 u := &CreateWorkflowDispatchEventRequest{ 625 Ref: "r", 626 Inputs: inputs, 627 } 628 629 want := `{ 630 "ref": "r", 631 "inputs": { 632 "key": "value" 633 } 634 }` 635 636 testJSONMarshal(t, u, want) 637 }