(t *testing.T, datatype string)
| 110 | } |
| 111 | |
| 112 | func InvalidDataTypeShowsError(t *testing.T, datatype string) { |
| 113 | definition := ` |
| 114 | paths: |
| 115 | /validate: |
| 116 | post: |
| 117 | requestBody: |
| 118 | content: |
| 119 | application/json: |
| 120 | schema: |
| 121 | properties: |
| 122 | myparameter: |
| 123 | type: ` + datatype + ` |
| 124 | nullable: false |
| 125 | ` |
| 126 | context := NewContextBuilder(). |
| 127 | WithDefinition("myservice", definition). |
| 128 | Build() |
| 129 | |
| 130 | result := RunCli([]string{"myservice", "post-validate", "--myparameter", "INVALID"}, context) |
| 131 | |
| 132 | expected := "Cannot convert 'myparameter' value 'INVALID' to " + datatype |
| 133 | if !strings.Contains(result.StdErr, expected) { |
| 134 | t.Errorf("stderr does not contain missing parameter error, expected: %v, got: %v", expected, result.StdErr) |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | func TestInvalidArrayDataTypesShowError(t *testing.T) { |
| 139 | t.Run("Integer", func(t *testing.T) { InvalidArrayDataTypeShowsError(t, "integer", "1,INVALID,3") }) |
no test coverage detected