Skip to content

Fixed AnyDecodableTests.testNull on iOS 12#1589

Merged
NachoSoto merged 1 commit into
mainfrom
any-decodable-ios-12-test
May 24, 2022
Merged

Fixed AnyDecodableTests.testNull on iOS 12#1589
NachoSoto merged 1 commit into
mainfrom
any-decodable-ios-12-test

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

Fixes https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/6737/workflows/b945f5f6-6f31-4716-b1ac-6e16e3848c7e/jobs/26321

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.})))

We don't rely on decoding fragments, so I just updated the test to check .null within a dictionary instead.

Fixes https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/6737/workflows/b945f5f6-6f31-4716-b1ac-6e16e3848c7e/jobs/26321

For some reason, on iOS 12.x only, this:
```swift
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.})))
```

We don't rely on decoding fragments, so I just updated the test to check `.null` within a dictionary instead.
@NachoSoto NachoSoto force-pushed the any-decodable-ios-12-test branch from 60df869 to 6823c7e Compare May 20, 2022 18:29
@NachoSoto NachoSoto merged commit f73ca91 into main May 24, 2022
@NachoSoto NachoSoto deleted the any-decodable-ios-12-test branch May 24, 2022 17:11
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