(id string, op PatchOperation)
| 204 | } |
| 205 | |
| 206 | func (h testResourceHandler) noContentOperation(id string, op PatchOperation) bool { |
| 207 | isRemoveOp := strings.EqualFold(op.Op, PatchOperationRemove) |
| 208 | |
| 209 | dataValue, ok := h.data[id] |
| 210 | if !ok { |
| 211 | return isRemoveOp |
| 212 | } |
| 213 | var path string |
| 214 | if op.Path != nil { |
| 215 | path = op.Path.String() |
| 216 | } |
| 217 | attrValue, ok := dataValue.resourceAttributes[path] |
| 218 | if ok && attrValue == op.Value { |
| 219 | return true |
| 220 | } |
| 221 | if !ok && isRemoveOp { |
| 222 | return true |
| 223 | } |
| 224 | |
| 225 | switch opValue := op.Value.(type) { |
| 226 | case map[string]interface{}: |
| 227 | for k, v := range opValue { |
| 228 | if v == dataValue.resourceAttributes[k] { |
| 229 | return true |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | case []map[string]interface{}: |
| 234 | for _, m := range opValue { |
| 235 | for k, v := range m { |
| 236 | if v == dataValue.resourceAttributes[k] { |
| 237 | return true |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | return false |
| 243 | } |
| 244 | |
| 245 | func (h testResourceHandler) shouldReturnNoContent(id string, ops []PatchOperation) bool { |
| 246 | for _, op := range ops { |
no test coverage detected