Skip to content

Added tests for PeriodType/PurchaseOwnershipType/Store#1558

Merged
NachoSoto merged 1 commit into
mainfrom
codable-types-tests
May 19, 2022
Merged

Added tests for PeriodType/PurchaseOwnershipType/Store#1558
NachoSoto merged 1 commit into
mainfrom
codable-types-tests

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

Follow up to #1551. Using Codable.encodeAndDecode we ensure that each value can be bidirectionally converted.
These tests exposed that unknown values were being encoded as null, but then failed to decode.

I've updated the implementation and added a few more tests to cover this behavior.

@NachoSoto NachoSoto requested a review from a team May 10, 2022 17:25
Base automatically changed from default-value-decoder to main May 10, 2022 17:26
@NachoSoto NachoSoto force-pushed the codable-types-tests branch 2 times, most recently from 859b659 to 1e14a85 Compare May 11, 2022 17:23
Follow up to #1551. Using `Codable.encodeAndDecode` we ensure that each value can be bidirectionally converted.
These tests exposed that unknown values were being encoded as `null`, but then failed to decode.

I've updated the implementation and added a few more tests to cover this behavior.
@NachoSoto NachoSoto force-pushed the codable-types-tests branch from 1e14a85 to 65db99a Compare May 11, 2022 17:24
@NachoSoto NachoSoto merged commit 56e3519 into main May 19, 2022
@NachoSoto NachoSoto deleted the codable-types-tests branch May 19, 2022 18:27
NachoSoto added a commit that referenced this pull request May 24, 2022
Follow up to #1589.
Fixes https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/6805/workflows/550827f9-ff8e-469d-b7a7-889417582eff/jobs/26743

Turns out the tests introduced in #1558 weren't compatible with iOS 12. As explained in #1589.
For some reason, on iOS 12.x only, this:
```
JSONDecoder.default.decode(jsonData: "null".data(using: .utf8)!)
```
Fails:

> dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.})))

Since iOS 12.x doesn't allow decoding top-level objects, I've simply disabled these tests. Decoding this types is already tested as part of other types. These new types only added more explicit testing.
NachoSoto added a commit that referenced this pull request May 24, 2022
Follow up to #1589.
Fixes https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/6805/workflows/550827f9-ff8e-469d-b7a7-889417582eff/jobs/26743

Turns out the tests introduced in #1558 weren't compatible with iOS 12. As explained in #1589.
For some reason, on iOS 12.x only, this:
```
JSONDecoder.default.decode(jsonData: "null".data(using: .utf8)!)
```
Fails:

> dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.})))

Since iOS 12.x doesn't allow decoding top-level objects, I've simply disabled these tests. Decoding this types is already tested as part of other types. These new types only added more explicit testing.
@joshdholtz joshdholtz mentioned this pull request May 26, 2022
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