Skip to content

Commit 5e125ab

Browse files
committed
fix another test
1 parent fd412a4 commit 5e125ab

1 file changed

Lines changed: 36 additions & 12 deletions

File tree

Tests/JSONAPITests/ResourceObject/ResourceObjectDecodingErrorTests.swift

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -498,20 +498,44 @@ extension ResourceObjectDecodingErrorTests {
498498
TestEntity2.self,
499499
from: entity_type_is_null
500500
)) { error in
501-
XCTAssertEqual(
502-
error as? ResourceObjectDecodingError,
503-
ResourceObjectDecodingError(
504-
subjectName: "type",
505-
cause: .valueNotFound,
506-
location: .type,
507-
jsonAPIType: TestEntity2.jsonType
501+
let specialError = error as? ResourceObjectDecodingError
502+
503+
XCTAssertNotNil(specialError)
504+
505+
// later Linux versions of Swift will catch that the value is not
506+
// a string rather than calling null "not found." The errors are both
507+
// effective, so we check that one of the two is the result:
508+
if specialError?.cause == .valueNotFound {
509+
XCTAssertEqual(
510+
specialError,
511+
ResourceObjectDecodingError(
512+
subjectName: "type",
513+
cause: .valueNotFound,
514+
location: .type,
515+
jsonAPIType: TestEntity2.jsonType
516+
)
508517
)
509-
)
510518

511-
XCTAssertEqual(
512-
(error as? ResourceObjectDecodingError)?.description,
513-
#"'type' (a.k.a. JSON:API type name) is not nullable but null was found."#
514-
)
519+
XCTAssertEqual(
520+
specialError?.description,
521+
"'type' (a.k.a. JSON:API type name) is not nullable but null was found."
522+
)
523+
} else {
524+
XCTAssertEqual(
525+
specialError,
526+
ResourceObjectDecodingError(
527+
subjectName: "type",
528+
cause: .typeMismatch(expectedTypeName: "String"),
529+
location: .type,
530+
jsonAPIType: TestEntity2.jsonType
531+
)
532+
)
533+
534+
XCTAssertEqual(
535+
specialError?.description,
536+
"'type' (a.k.a. JSON:API type name) is not a String as expected."
537+
)
538+
}
515539
}
516540
}
517541
}

0 commit comments

Comments
 (0)