(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func TestPatch_complex(t *testing.T) { |
| 153 | raw, err := ioutil.ReadFile("testdata/patch/add/complex.json") |
| 154 | if err != nil { |
| 155 | t.Fatal(err) |
| 156 | } |
| 157 | var ( |
| 158 | req = httptest.NewRequest(http.MethodPatch, "/Users/0001", bytes.NewReader(raw)) |
| 159 | rr = httptest.NewRecorder() |
| 160 | ) |
| 161 | newTestServer().ServeHTTP(rr, req) |
| 162 | if rr.Code != http.StatusOK { |
| 163 | t.Fatal(rr.Code, rr.Body.String()) |
| 164 | } |
| 165 | var resource map[string]interface{} |
| 166 | if err := json.Unmarshal(rr.Body.Bytes(), &resource); err != nil { |
| 167 | t.Fatal(err) |
| 168 | } |
| 169 | rm, ok := resource["name"] |
| 170 | if !ok { |
| 171 | t.Fatal(resource["members"]) |
| 172 | } |
| 173 | m, ok := rm.(map[string]interface{}) |
| 174 | if !ok { |
| 175 | t.Fatal(rm) |
| 176 | } |
| 177 | if m["givenName"] != "Barbara" { |
| 178 | t.Error(m["givenName"]) |
| 179 | } |
| 180 | if m["familyName"] != "Jensen" { |
| 181 | t.Error(m["familyName"]) |
| 182 | } |
| 183 | if m["formatted"] != "Barbara Jensen" { |
| 184 | t.Error(m["formatted"]) |
| 185 | } |
| 186 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…