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

Remove namespace redundancy when generating json #52

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

kkoehn
Copy link
Collaborator

@kkoehn kkoehn commented Oct 3, 2023

This change adds an additional requirement for a namespace to be added to the namespace attribute in the json format:

  • the parent node must not also have this namespace (prefix and href get both checked)

@kkoehn kkoehn self-assigned this Oct 3, 2023
@kkoehn kkoehn requested a review from MrSerth October 3, 2023 11:45
Copy link
Member

@MrSerth MrSerth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, what a simple fix! I actually spent some time to understand its cleverness and think it is suitable for our use case 👍

While checking the code, I also came up with a test for a bidirectional test -- it simply checks whether the XML -> JSON -> XML conversation (or JSON -> XML -> JSON) is performed without any change: bidirectional_converter_spec.rb.zip

I would propose adding it as well to our test suite -- just to be sure that a similar mistake cannot slip in again.

@kkoehn
Copy link
Collaborator Author

kkoehn commented Oct 3, 2023

Awesome, what a simple fix! I actually spent some time to understand its cleverness and think it is suitable for our use case 👍

Thanks for the feedback!

While checking the code, I also came up with a test for a bidirectional test -- it simply checks whether the XML -> JSON -> XML conversation (or JSON -> XML -> JSON) is performed without any change: bidirectional_converter_spec.rb.zip

I would propose adding it as well to our test suite -- just to be sure that a similar mistake cannot slip in again.

Do you think it fits in the scope of this PR? I don't see any direct ties.

@MrSerth
Copy link
Member

MrSerth commented Oct 3, 2023

Do you think it fits in the scope of this PR? I don't see any direct ties.

Somewhat. The tests I provided wouldn't pass without your change, so that they cannot be added earlier. However, as soon as this PR is merged, it can be added at any time.

I thought it would fit somewhat in the scope of this PR, since this PR resolves an issue that was previously preventing the bidirectional conversion to function correctly.

Nevertheless, I am also fine to merge this PR and just open another one with my changes 😁

@kkoehn
Copy link
Collaborator Author

kkoehn commented Oct 3, 2023

Somewhat. The tests I provided wouldn't pass without your change, so that they cannot be added earlier. However, as soon as this PR is merged, it can be added at any time.

Weird - I tried adding the test directly to main and it works fine for me 😕

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #52 (f0f59b0) into main (a8a44a0) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main       #52   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          315       315           
=========================================
  Hits           315       315           
Files Coverage Δ
lib/dachsfisch/xml2_json_converter.rb 100.00% <100.00%> (ø)
spec/support/examples.rb 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kkoehn
Copy link
Collaborator Author

kkoehn commented Oct 3, 2023

Nonetheless, feel free to commit it to this PR to reduce the overhead

@MrSerth
Copy link
Member

MrSerth commented Oct 3, 2023

Weird - I tried adding the test directly to main and it works fine for me 😕

You're right, I see that as well. Obviously, the issue is with the be_equivalent_to, which smartly checks for the namespace (this is the only case it would break).

I'll merge this PR and will open another one with my changes soon. Then, we can continue the discussion there.

@MrSerth MrSerth merged commit e21cc91 into main Oct 3, 2023
7 checks passed
@MrSerth MrSerth deleted the fix_redundant_namespaces branch October 3, 2023 18:43
MrSerth added a commit that referenced this pull request Oct 3, 2023
Previously, we might have duplicated namespaces when converting the same string back and forth. With the latest change in #52, we're avoiding this error and are now adding respective test coverage for this phenomena.
MrSerth added a commit that referenced this pull request Oct 9, 2023
Previously, we might have duplicated namespaces when converting the same string back and forth. With the latest change in #52, we're avoiding this error and are now adding respective test coverage for this phenomena.
MrSerth added a commit that referenced this pull request Oct 10, 2023
Previously, we might have duplicated namespaces when converting the same string back and forth. With the latest change in #52, we're avoiding this error and are now adding respective test coverage for this phenomena.
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