(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestNewPathValidator(t *testing.T) { |
| 11 | t.Run("Invalid JSON", func(t *testing.T) { |
| 12 | // The quotes in the value filter are not escaped. |
| 13 | op := `{"op":"add","path":"complexMultiValued[attr1 eq "value"].attr1","value":"value"}` |
| 14 | if _, err := NewValidator(op, patchSchema); err == nil { |
| 15 | t.Error("expected JSON error, got none") |
| 16 | } |
| 17 | }) |
| 18 | t.Run("Invalid Op", func(t *testing.T) { |
| 19 | // "op" must be one of "add", "remove", or "replace". |
| 20 | op := `{"op":"invalid","path":"attr1","value":"value"}` |
| 21 | validator, _ := NewValidator(op, patchSchema) |
| 22 | if _, err := validator.Validate(); err == nil { |
| 23 | t.Errorf("expected error, got none") |
| 24 | } |
| 25 | }) |
| 26 | t.Run("Invalid Attribute", func(t *testing.T) { |
| 27 | // "invalid pr" is not a valid path filter. |
| 28 | // This error will be caught by the path filter validator. |
| 29 | op := `{"op":"add","path":"invalid pr","value":"value"}` |
| 30 | if _, err := NewValidator(op, patchSchema); err == nil { |
| 31 | t.Error("expected JSON error, got none") |
| 32 | } |
| 33 | }) |
| 34 | } |
| 35 | |
| 36 | func TestOperationValidator_getRefAttribute(t *testing.T) { |
| 37 | for _, test := range []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…