TestExtractUnknownParams verifies that the error-message parser correctly extracts unknown parameter names from the jsonschema-go validation error.
(t *testing.T)
| 33 | // TestExtractUnknownParams verifies that the error-message parser correctly |
| 34 | // extracts unknown parameter names from the jsonschema-go validation error. |
| 35 | func TestExtractUnknownParams(t *testing.T) { |
| 36 | tests := []struct { |
| 37 | name string |
| 38 | errMsg string |
| 39 | expected []string |
| 40 | }{ |
| 41 | { |
| 42 | name: "single unknown param", |
| 43 | errMsg: `validating "arguments": validating root: unexpected additional properties ["workflow-name"]`, |
| 44 | expected: []string{"workflow-name"}, |
| 45 | }, |
| 46 | { |
| 47 | name: "multiple unknown params", |
| 48 | errMsg: `validating "arguments": validating root: unexpected additional properties ["workflow-name" "invalid-param"]`, |
| 49 | expected: []string{"workflow-name", "invalid-param"}, |
| 50 | }, |
| 51 | { |
| 52 | name: "underscore param", |
| 53 | errMsg: `validating "arguments": validating root: unexpected additional properties ["workflow_name"]`, |
| 54 | expected: []string{"workflow_name"}, |
| 55 | }, |
| 56 | { |
| 57 | name: "no match — different error", |
| 58 | errMsg: "some other validation error", |
| 59 | expected: nil, |
| 60 | }, |
| 61 | { |
| 62 | name: "empty string", |
| 63 | errMsg: "", |
| 64 | expected: nil, |
| 65 | }, |
| 66 | } |
| 67 | |
| 68 | for _, tt := range tests { |
| 69 | t.Run(tt.name, func(t *testing.T) { |
| 70 | got := extractUnknownParams(tt.errMsg) |
| 71 | assert.Equal(t, tt.expected, got, "extracted unknown params should match") |
| 72 | }) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func TestExtractUnknownParamsFromSchemaError(t *testing.T) { |
| 77 | type sampleArgs struct { |
nothing calls this directly
no test coverage detected