@@ -103,20 +103,44 @@ final class ResourceObjectDecodingErrorTests: XCTestCase {
103103 TestEntity . self,
104104 from: entity_nonNullable_relationship_is_null
105105 ) ) { error in
106- XCTAssertEqual (
107- error as? ResourceObjectDecodingError ,
108- ResourceObjectDecodingError (
109- subjectName: " required " ,
110- cause: . valueNotFound,
111- location: . relationships,
112- jsonAPIType: TestEntity . jsonType
106+ let specialError = error as? ResourceObjectDecodingError
107+
108+ XCTAssertNotNil ( specialError)
109+
110+ // later Linux versions of Swift will catch that the value is not
111+ // a string rather than calling null "not found." The errors are both
112+ // effective, so we check that one of the two is the result:
113+ if specialError? . cause == . valueNotFound {
114+ XCTAssertEqual (
115+ specialError,
116+ ResourceObjectDecodingError (
117+ subjectName: " required " ,
118+ cause: . valueNotFound,
119+ location: . relationships,
120+ jsonAPIType: TestEntity . jsonType
121+ )
113122 )
114- )
115123
116- XCTAssertEqual (
117- ( error as? ResourceObjectDecodingError ) ? . description,
118- " 'required' relationship is not nullable but null was found. "
119- )
124+ XCTAssertEqual (
125+ specialError? . description,
126+ " 'required' relationship is not nullable but null was found. "
127+ )
128+ } else {
129+ XCTAssertEqual (
130+ specialError,
131+ ResourceObjectDecodingError (
132+ subjectName: " required " ,
133+ cause: . typeMismatch( expectedTypeName: " Dictionary<String, JSONValue> " ) ,
134+ location: . relationships,
135+ jsonAPIType: TestEntity . jsonType
136+ )
137+ )
138+
139+ XCTAssertEqual (
140+ specialError? . description,
141+ " 'required' relationship is not a Dictionary<String, JSONValue> as expected. "
142+ )
143+ }
120144 }
121145 }
122146
@@ -259,20 +283,44 @@ extension ResourceObjectDecodingErrorTests {
259283 TestEntity2 . self,
260284 from: entity_nonNullable_attribute_is_null
261285 ) ) { error in
262- XCTAssertEqual (
263- error as? ResourceObjectDecodingError ,
264- ResourceObjectDecodingError (
265- subjectName: " required " ,
266- cause: . valueNotFound,
267- location: . attributes,
268- jsonAPIType: TestEntity2 . jsonType
286+ let specialError = error as? ResourceObjectDecodingError
287+
288+ XCTAssertNotNil ( specialError)
289+
290+ // later Linux versions of Swift will catch that the value is not
291+ // a string rather than calling null "not found." The errors are both
292+ // effective, so we check that one of the two is the result:
293+ if specialError? . cause == . valueNotFound {
294+ XCTAssertEqual (
295+ specialError,
296+ ResourceObjectDecodingError (
297+ subjectName: " required " ,
298+ cause: . valueNotFound,
299+ location: . attributes,
300+ jsonAPIType: TestEntity2 . jsonType
301+ )
269302 )
270- )
271303
272- XCTAssertEqual (
273- ( error as? ResourceObjectDecodingError ) ? . description,
274- " 'required' attribute is not nullable but null was found. "
275- )
304+ XCTAssertEqual (
305+ specialError? . description,
306+ " 'required' attribute is not nullable but null was found. "
307+ )
308+ } else {
309+ XCTAssertEqual (
310+ specialError,
311+ ResourceObjectDecodingError (
312+ subjectName: " required " ,
313+ cause: . typeMismatch( expectedTypeName: " String " ) ,
314+ location: . attributes,
315+ jsonAPIType: TestEntity2 . jsonType
316+ )
317+ )
318+
319+ XCTAssertEqual (
320+ specialError? . description,
321+ " 'required' attribute is not a String as expected. "
322+ )
323+ }
276324 }
277325 }
278326
0 commit comments