(t *testing.T, itemsType string, argument string, queryStringValue string)
| 540 | } |
| 541 | |
| 542 | func RequestWithQueryStringParameterArray(t *testing.T, itemsType string, argument string, queryStringValue string) { |
| 543 | definition := ` |
| 544 | paths: |
| 545 | /ping: |
| 546 | parameters: |
| 547 | - name: id |
| 548 | in: query |
| 549 | required: true |
| 550 | description: The id |
| 551 | schema: |
| 552 | type: array |
| 553 | items: |
| 554 | type: ` + itemsType + ` |
| 555 | get: |
| 556 | operationId: ping |
| 557 | summary: Simple ping |
| 558 | ` |
| 559 | context := NewContextBuilder(). |
| 560 | WithResponse(http.StatusOK, "{}"). |
| 561 | WithDefinition("myservice", definition). |
| 562 | Build() |
| 563 | |
| 564 | result := RunCli([]string{"myservice", "ping", "--id", argument}, context) |
| 565 | |
| 566 | expected := "/ping?" + queryStringValue |
| 567 | if result.RequestUrl != expected { |
| 568 | t.Errorf("Invalid request url, expected: %v, got: %v", expected, result.RequestUrl) |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | func TestRequestWithPathParameterDataTypes(t *testing.T) { |
| 573 | t.Run("String", func(t *testing.T) { RequestWithPathParameterDataType(t, "string", "myvalue", "myvalue") }) |
no test coverage detected