MCPcopy Create free account
hub / github.com/elimity-com/scim / noContentOperation

Method noContentOperation

resource_handler_test.go:206–243  ·  view source on GitHub ↗
(id string, op PatchOperation)

Source from the content-addressed store, hash-verified

204}
205
206func (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
245func (h testResourceHandler) shouldReturnNoContent(id string, ops []PatchOperation) bool {
246 for _, op := range ops {

Callers 1

shouldReturnNoContentMethod · 0.95

Calls 1

StringMethod · 0.80

Tested by

no test coverage detected