Skip to content

Commit 93efa69

Browse files
committed
make coding keys private again and test the error description instead of the error enum
1 parent fd514b1 commit 93efa69

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

Sources/JSONAPI/Resource/Relationship.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ extension Optional: JSONAPIIdentifiable, OptionalRelatable, JSONTyped where Wrap
222222
}
223223

224224
// MARK: Codable
225-
enum ResourceLinkageCodingKeys: String, CodingKey {
225+
private enum ResourceLinkageCodingKeys: String, CodingKey {
226226
case data = "data"
227227
case meta = "meta"
228228
case links = "links"

Tests/JSONAPITests/Relationships/RelationshipTests.swift

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
import XCTest
9-
@testable import JSONAPI
9+
import JSONAPI
1010

1111
class RelationshipTests: XCTestCase {
1212

@@ -251,19 +251,11 @@ extension RelationshipTests {
251251
func test_ToManyRelationshipWithMetaNoDataNotOmittable() {
252252
TestEntityType1.canHaveNoDataInRelationships = false
253253

254-
do {
255-
_ = try decodedThrows(type: ToManyWithMeta.self,
256-
data: to_many_relationship_with_meta_no_data)
257-
XCTFail("Expected decoding to fail.")
258-
} catch let error as DecodingError {
259-
switch error {
260-
case .keyNotFound(ResourceLinkageCodingKeys.data, _):
261-
break
262-
default:
263-
XCTFail("Expected error to be DecodingError.keyNotFound(.data), but got \(error)")
264-
}
265-
} catch {
266-
XCTFail("Expected to have DecodingError.keyNotFound(.data), but got \(error)")
254+
XCTAssertThrowsError(
255+
try decodedThrows(type: ToManyWithMeta.self,
256+
data: to_many_relationship_with_meta_no_data)
257+
) { error in
258+
XCTAssertEqual(error.localizedDescription, "The data couldn’t be read because it is missing.")
267259
}
268260
}
269261
}

0 commit comments

Comments
 (0)