-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: MLIBZ-3195, Codable support for File #378
Conversation
* Make `File` conform to `JSONCodable` protocol * Add implementations for `encode(to)` and `init(from)` * Copy `EntityCodingKeys` values to `FileCodingKeys` because `Codable` implementation methods must use values from one enum only and (afaik) enums cannot have their values assigned from other enums * Use `parseObject` which works with both `Mappable` and `Codable` instead of `parseDictionary` in `FileStore` * Use `jsonParser.toJSON` instead of `file.toJSON()` which automatically handles both cases as well * Remove empty `_requiredHeaders` from test cases because it's treated as an empty array when deserialized with `Decoder` in `init(from)`. And add a `TEST_HEADER` header in one test scenario (`testCreateBucketInputStream`) * Add test cases for both `Encodable` and the deprecated `Mappable` serialization approaches by making `FileTestCase` a generic base class and inheriting it with 2 concrete Test classes
f4854a7
to
99a1da8
Compare
Codecov Report
@@ Coverage Diff @@
## develop #378 +/- ##
==========================================
- Coverage 86.26% 80.86% -5.4%
==========================================
Files 82 82
Lines 10149 10198 +49
==========================================
- Hits 8755 8247 -508
- Misses 1394 1951 +557
Continue to review full report at Codecov.
|
Carthage sporadically crashes with segmentation fault in the current latest version (0.34.0). As a workaround downgrade to 0.33.0 but only if it is 0.34.0. refs Carthage/Carthage#2760
25d01dc
to
3702ab2
Compare
Set it to 13.3 to match that of Xcode 11.3.1 used in Cirrus CI
Codecov Report
@@ Coverage Diff @@
## develop #378 +/- ##
===========================================
- Coverage 86.26% 80.86% -5.40%
===========================================
Files 82 82
Lines 10149 10198 +49
===========================================
- Hits 8755 8247 -508
- Misses 1394 1951 +557
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #378 +/- ##
===========================================
- Coverage 86.26% 86.13% -0.14%
===========================================
Files 82 82
Lines 10149 10212 +63
===========================================
+ Hits 8755 8796 +41
- Misses 1394 1416 +22
Continue to review full report at Codecov.
|
Implement test runner classes for TestCases that use generic classes based on this answer in SO: https://stackoverflow.com/a/39101121/311889 Without such workaround these test cases could only be launched manually from the UI, but they never started when launching from the test scheme.
1740345
to
8cf1803
Compare
When Realm's files are located inside the temporary test directory of `XCTestConfigurationFilePath`, Xcode 11.3.1 hangs indefinitely after the test run finishes. If they're outside of it, the test run completes normally. As a solution on macOS: * Place the cache directory below the temp directory * Append `processIdentifier` as a subdirectory to allow for parallel runs
8cf1803
to
6a9e1c8
Compare
Codecov Report
@@ Coverage Diff @@
## develop #378 +/- ##
===========================================
- Coverage 86.26% 86.13% -0.14%
===========================================
Files 82 82
Lines 10149 10212 +63
===========================================
+ Hits 8755 8796 +41
- Misses 1394 1416 +22
Continue to review full report at Codecov.
|
These new cases increase coverage and state the difference of behaviour between Codable and Mappable implementations
Codecov Report
@@ Coverage Diff @@
## develop #378 +/- ##
===========================================
- Coverage 86.26% 86.13% -0.14%
===========================================
Files 82 82
Lines 10149 10212 +63
===========================================
+ Hits 8755 8796 +41
- Misses 1394 1416 +22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #378 +/- ##
===========================================
- Coverage 86.26% 86.13% -0.14%
===========================================
Files 82 82
Lines 10149 10212 +63
===========================================
+ Hits 8755 8796 +41
- Misses 1394 1416 +22
Continue to review full report at Codecov.
|
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.
Hi Martin, this is working fine. I was able to implement the codable protocol for my custom file class. I tried uploading a file using this custom class and I can see the custom property is sent properly to the Kinvey backend. Just to confirm, I downloaded the same file from the backend and I can see the custom property was present in the download response also. So I believe we are all set here.
LGTM. |
Description
Fixes issue Custom properties of class inherited from
File
and adoptingCodable
protocol are not sent to the backendSteps to reproduce:
File
Codable
protocol adoptionActual Result:
Method
encode(to encoder: Encoder)
is not called. Any custom properties from the class are not sent to Kinvey.Expected Result:
Custom properties are sent to Kinvey along with default
File
class properties.Changes
Make
File
conform toJSONCodable
protocolAdd implementations for
encode(to)
andinit(from)
Copy
EntityCodingKeys
values toFileCodingKeys
because
Codable
implementation methods must usevalues from one enum only and (afaik) enums cannot
have their values assigned from other enums
Use
parseObject
which works with bothMappable
and
Codable
instead ofparseDictionary
inFileStore
Use
jsonParser.toJSON
instead offile.toJSON()
whichautomatically handles both cases as well
Tests
Remove empty
_requiredHeaders
from test casesbecause it's treated as an empty array when deserialized
with
Decoder
ininit(from)
. And add aTEST_HEADER
header in one test scenario (
testCreateBucketInputStream
)Add test cases for both
Encodable
and the deprecatedMappable
serialization approaches by makingFileTestCase
a generic base class and inheriting it with 2 concrete Test
classes