I'm setting up unit testing using marklogic-unit-test and one thing I'd like to do is check a given document has a particular permission. However, when I test my permission against a Sequence of permissions, I get an XDMP-NONMIXEDCOMPLEXCONT
error. I assume this has to do with the fact that permissions are complex objects and not something like a simple string, because this works with collections.
const test = require("/test/test-helper.xqy");
let p1 = Sequence.from([xdmp.permission("rest-reader", "read", "element")]);
let p2 = Sequence.from([
xdmp.permission("rest-reader", "read", "element"),
xdmp.permission("rest-writer", "update", "element")
]);
test.assertAtLeastOneEqual(p1, p2)
Which returns:
[javascript] XDMP-NONMIXEDCOMPLEXCONT: fn:data(<sec:permission
xmlns:sec="http://marklogic.com/xdmp/security">
<sec:capability>...</sec:capability>...</sec:permission>)
-- Node has complex type with non-mixed complex content
The best alternative I can come up with is to explicitly loop over the Sequence and do the comparison with fn.deepEqual
on each element. Is there a better way?