Skip to content

Commit 9a1914a

Browse files
committed
Test throwing record row accessors
1 parent 4a92263 commit 9a1914a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Tests/GRDBTests/AssociationBelongsToFetchableRecordTests.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ private struct PlayerWithRequiredTeam: FetchableRecord {
2222

2323
init(row: Row) throws {
2424
player = try Player(row: row)
25-
team = row[Player.teamScope]
25+
let subscriptTeam: Team = row[Player.teamScope]
26+
let decodedTeam: Team = try row.decode(forKey: Player.teamScope)
27+
XCTAssertEqual(subscriptTeam.id, decodedTeam.id)
28+
team = subscriptTeam
2629
}
2730
}
2831

@@ -32,7 +35,10 @@ private struct PlayerWithOptionalTeam: FetchableRecord {
3235

3336
init(row: Row) throws {
3437
player = try Player(row: row)
35-
team = row[Player.teamScope]
38+
let subscriptTeam: Team? = row[Player.teamScope]
39+
let decodedTeam: Team? = try row.decodeIfPresent(forKey: Player.teamScope)
40+
XCTAssertEqual(subscriptTeam?.id, decodedTeam?.id)
41+
team = subscriptTeam
3642
}
3743
}
3844

0 commit comments

Comments
 (0)