At present all PATCH requests for resources that have a meta.version attribute will fail with ErrConflict because the PatchService.Do() method incorrectly mutates the current resource instead of its replacement.
This has the effect of permitting replacements when there is no version present -- which is the case for the existing unit tests but not real APIs. Simply adding a meta.version attribute to unit tests (as in this PR) yields failures like as the following for all tests:
=== RUN TestPatchService/TestDo/patch_to_make_a_difference
patch_test.go:99:
Error Trace: patch_test.go:99
patch_test.go:366
Error: Expected nil, but got: &spec.Error{Status:412, Type:"conflict"}
Test: TestPatchService/TestDo/patch_to_make_a_difference
An identical fix was originally proposed by @zakirhussain in #80. This PR expands on that work to include unit test changes to catch a regression and (hopefully) a better explanation of the underlying cause of the issue.
At present all PATCH requests for resources that have a
meta.version
attribute will fail withErrConflict
because thePatchService.Do()
method incorrectly mutates the current resource instead of its replacement.This error was not caught by existing unit tests because they do not set a
meta.version
attribute anddb.Memory().Replace()
has the following check: https://github.com/imulab/go-scim/blob/fec7838ed1c454d176f882e8c6cc73f094068697/pkg/v2/db/memory.go#L76-L79This has the effect of permitting replacements when there is no version present -- which is the case for the existing unit tests but not real APIs. Simply adding a
meta.version
attribute to unit tests (as in this PR) yields failures like as the following for all tests:An identical fix was originally proposed by @zakirhussain in #80. This PR expands on that work to include unit test changes to catch a regression and (hopefully) a better explanation of the underlying cause of the issue.