|
7 | 7 | "testing"
|
8 | 8 |
|
9 | 9 | "github.com/google/go-cmp/cmp"
|
10 |
| - "github.com/hashicorp/terraform-provider-aws/internal/acctest/jsoncmp" |
11 | 10 | tfjson "github.com/hashicorp/terraform-provider-aws/internal/json"
|
12 | 11 | mattbairdjsonpatch "github.com/mattbaird/jsonpatch"
|
13 | 12 | )
|
@@ -84,67 +83,3 @@ func TestCreatePatchFromStrings(t *testing.T) {
|
84 | 83 | })
|
85 | 84 | }
|
86 | 85 | }
|
87 |
| - |
88 |
| -func TestCreateMergePatchFromStrings(t *testing.T) { |
89 |
| - t.Parallel() |
90 |
| - |
91 |
| - testCases := []struct { |
92 |
| - testName string |
93 |
| - a, b string |
94 |
| - wantPatch string |
95 |
| - wantErr bool |
96 |
| - }{ |
97 |
| - { |
98 |
| - testName: "invalid JSON", |
99 |
| - a: `test`, |
100 |
| - b: `{}`, |
101 |
| - wantErr: true, |
102 |
| - }, |
103 |
| - { |
104 |
| - testName: "empty patch, empty JSON", |
105 |
| - a: `{}`, |
106 |
| - b: `{}`, |
107 |
| - wantPatch: `{}`, |
108 |
| - }, |
109 |
| - { |
110 |
| - testName: "empty patch, non-empty JSON", |
111 |
| - a: `{"A": "test1", "B": 42}`, |
112 |
| - b: `{"B": 42, "A": "test1"}`, |
113 |
| - wantPatch: `{}`, |
114 |
| - }, |
115 |
| - { |
116 |
| - testName: "from empty JSON", |
117 |
| - a: `{}`, |
118 |
| - b: `{"A": "test1", "B": 42}`, |
119 |
| - wantPatch: `{"A":"test1", "B":42}`, |
120 |
| - }, |
121 |
| - { |
122 |
| - testName: "to empty JSON", |
123 |
| - a: `{"A": "test1", "B": 42}`, |
124 |
| - b: `{}`, |
125 |
| - wantPatch: `{"A":null, "B":null}`, |
126 |
| - }, |
127 |
| - { |
128 |
| - testName: "change values", |
129 |
| - a: `{"A": "test1", "B": 42}`, |
130 |
| - b: `{"A": ["test2"], "B": 42}`, |
131 |
| - wantPatch: `{"A": ["test2"]}`, |
132 |
| - }, |
133 |
| - } |
134 |
| - |
135 |
| - for _, testCase := range testCases { |
136 |
| - t.Run(testCase.testName, func(t *testing.T) { |
137 |
| - t.Parallel() |
138 |
| - |
139 |
| - got, err := tfjson.CreateMergePatchFromStrings(testCase.a, testCase.b) |
140 |
| - if got, want := err != nil, testCase.wantErr; !cmp.Equal(got, want) { |
141 |
| - t.Errorf("CreateMergePatchFromStrings(%s, %s) err %t, want %t", testCase.a, testCase.b, got, want) |
142 |
| - } |
143 |
| - if err == nil { |
144 |
| - if diff := jsoncmp.Diff(got, testCase.wantPatch); diff != "" { |
145 |
| - t.Errorf("unexpected diff (+wanted, -got): %s", diff) |
146 |
| - } |
147 |
| - } |
148 |
| - }) |
149 |
| - } |
150 |
| -} |
0 commit comments