This PR contains the work done to decouple the direct use of the `ModelContext` from `SwiftData` from the view model that uses it. In addition, the project transitioned to use Swift 6 and strict concurrency which brought some issues with the unit tests, so they were amended as well. Reviewed-on: rock-n-code/todos-app#8 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
13 lines
567 B
Swift
13 lines
567 B
Swift
import SwiftData
|
|
|
|
/// Extends ModelContext to conform to the TodoRepository protocol.
|
|
///
|
|
/// This extension allows ModelContext from SwiftData to be used as a todo repository,
|
|
/// enabling dependency injection and facilitating unit testing by allowing mock
|
|
/// repositories to be substituted during tests.
|
|
///
|
|
/// The ModelContext methods `delete(_:)` and `insert(_:)` already match the
|
|
/// TodoRepository protocol requirements, so this extension simply declares conformance
|
|
/// without requiring additional implementation.
|
|
extension ModelContext: TodoRepository {}
|