-
Notifications
You must be signed in to change notification settings - Fork 9
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
Use a private encoder to compare messages, if needed #21
Conversation
Can you elaborate on the broken test? I'm not seeing any failures: https://github.com/hotwired/strada-ios/actions Where did you find that checking message equality is necessary? |
Actually, the CI threw me for a loop once I opened the PR. I worked on #22 and when I ran the tests locally,
As you can see, the Strings are clearly not the same:
So I don't understand how it's passing on CI. I see we're using Xcode 14.2 so I'm downloading it to test it.
Message conforms to |
Good catch @olivaresf! Why is the test failing? @olivaresf solution is good and solves the problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olivaresf The custom equality implementation is great. I've left a few comments to keep the code tidy.
Source/Message.swift
Outdated
|
||
/// Used to compare `jsonData` Strings. | ||
private static let equalityJSONEncoder = JSONEncoder() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed since it's unused.
Source/Message.swift
Outdated
|
||
extension Message { | ||
|
||
/// Using `Equatable`'s default implementation is bound to give us false positives since two `Message`s may have semantically equal, but textually different, `jsonData`. | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since comparing messages is an implementation detail, I'd move this to its own extension file, Message+Equatable
. This will also keep the Message
interface clean.
Ah, thanks for the explanation 🙏 |
@joemasilotti I've addressed the issues. Should be good to go, but please give it another look. cc @olivaresf |
FYI, the tests are failing due to timing issues. We should probably consider migrating |
I took a first pass in #26. I'm not sure how I like exposing the public API to Strada as async functions, though. Thoughts on that? |
This will be addressed in #29. |
Main has a single test broken:
test_encodingWithCustomEncoder
. The reason for this is that comparing two Messages isn't straightforward since their JSON values are saved as Strings.