Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for JSON Patch test operations #624

Merged
merged 7 commits into from
Mar 19, 2024
Merged

Conversation

jjjake
Copy link
Owner

@jjjake jjjake commented Feb 2, 2024

No description provided.

@jjjake jjjake changed the title first pass at adding support for JSON Patch test operations. Add support for JSON Patch test operations Feb 2, 2024
@MerlijnWajer
Copy link

I changed the loop to this to make insert / append-list / remove for lists work, at least in some light testing:

for p in patch:
    path_parts = p['path'].split('/')
    if not source_metadata.get(path_parts[1]):
        continue
    if len(path_parts) == 2:
        src_val = source_metadata.get(path_parts[-1])
        p_test = {'op': 'test', 'path': p['path'], 'value': src_val}
    else:
        src_val = source_metadata.get(path_parts[1], [])
        p_test = {'op': 'test', 'path': '/' + path_parts[1], 'value': src_val}

    patch_tests.append(p_test)

@jjjake
Copy link
Owner Author

jjjake commented Feb 6, 2024

Thanks @MerlijnWajer! I just pushed a patch with your fix.

@jjjake jjjake merged commit aae9ef2 into master Mar 19, 2024
4 of 22 checks passed
@jjjake jjjake deleted the json-patch-test-operator branch March 19, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants