(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func Test_JSONDiffWithRegex(t *testing.T) { |
| 30 | expected := []byte(`{ |
| 31 | "a": "^0\\d+$", |
| 32 | "b": { |
| 33 | "c": "^[a-z]0[A-Z]$", |
| 34 | "d": [ |
| 35 | { |
| 36 | "e": "^[0-5]$" |
| 37 | } |
| 38 | ] |
| 39 | } |
| 40 | }`) |
| 41 | |
| 42 | cases := []struct { |
| 43 | name string |
| 44 | expected []byte |
| 45 | right string |
| 46 | modified bool |
| 47 | }{ |
| 48 | { |
| 49 | name: "passing", |
| 50 | expected: expected, |
| 51 | right: `{ |
| 52 | "a": "0123", |
| 53 | "b": { |
| 54 | "c": "a0B", |
| 55 | "d": [ |
| 56 | {"e": 1} |
| 57 | ] |
| 58 | } |
| 59 | }`, |
| 60 | modified: false, |
| 61 | }, |
| 62 | { |
| 63 | name: "failing nested", |
| 64 | expected: expected, |
| 65 | right: `{ |
| 66 | "a": "0123", |
| 67 | "b": { |
| 68 | "c": "a0B", |
| 69 | "d": [ |
| 70 | {"e": 10} |
| 71 | ] |
| 72 | } |
| 73 | }`, |
| 74 | modified: true, |
| 75 | }, |
| 76 | { |
| 77 | name: "failing", |
| 78 | expected: expected, |
| 79 | right: `{ |
| 80 | "a": "123", |
| 81 | "b": { |
| 82 | "c": "B2a", |
| 83 | "d": [ |
| 84 | {"e": 6}, |
| 85 | {"e": 10} |
| 86 | ] |
nothing calls this directly
no test coverage detected