TestBuildHelpfulParamError verifies the structure of the helpful error message.
(t *testing.T)
| 163 | |
| 164 | // TestBuildHelpfulParamError verifies the structure of the helpful error message. |
| 165 | func TestBuildHelpfulParamError(t *testing.T) { |
| 166 | t.Run("single unknown param with suggestion", func(t *testing.T) { |
| 167 | msg := buildHelpfulParamError( |
| 168 | "compile", |
| 169 | []string{"workflow-name"}, |
| 170 | []string{"workflows", "strict"}, |
| 171 | ) |
| 172 | assert.Contains(t, msg, "Unknown parameter 'workflow-name'", "should mention unknown param") |
| 173 | assert.Contains(t, msg, "Did you mean 'workflows'?", "should suggest workflows") |
| 174 | assert.Contains(t, msg, "agenticworkflows compile --help", "should point to help") |
| 175 | }) |
| 176 | |
| 177 | t.Run("single unknown param without suggestion", func(t *testing.T) { |
| 178 | msg := buildHelpfulParamError( |
| 179 | "compile", |
| 180 | []string{"banana"}, |
| 181 | []string{"workflows", "strict"}, |
| 182 | ) |
| 183 | assert.Contains(t, msg, "Unknown parameter 'banana'", "should mention unknown param") |
| 184 | assert.NotContains(t, msg, "Did you mean", "should not suggest for unrelated param") |
| 185 | assert.Contains(t, msg, "agenticworkflows compile --help", "should point to help") |
| 186 | }) |
| 187 | |
| 188 | t.Run("multiple unknown params", func(t *testing.T) { |
| 189 | msg := buildHelpfulParamError( |
| 190 | "compile", |
| 191 | []string{"workflow-name", "abc"}, |
| 192 | []string{"workflows", "strict"}, |
| 193 | ) |
| 194 | assert.Contains(t, msg, "Unknown parameter 'workflow-name'", "should mention first unknown param") |
| 195 | assert.Contains(t, msg, "Unknown parameter 'abc'", "should mention second unknown param") |
| 196 | assert.Contains(t, msg, "agenticworkflows compile --help", "should point to help") |
| 197 | }) |
| 198 | |
| 199 | t.Run("empty tool name omits help line", func(t *testing.T) { |
| 200 | msg := buildHelpfulParamError("", []string{"workflow-name"}, []string{"workflows"}) |
| 201 | assert.NotContains(t, msg, "--help", "no tool name means no help line") |
| 202 | }) |
| 203 | } |
| 204 | |
| 205 | // TestArgumentValidationMiddleware_TransformsAdditionalPropertiesError verifies |
| 206 | // that the middleware replaces raw schema validation errors with helpful messages. |
nothing calls this directly
no test coverage detected