diff --git a/Sources/Dependencies/Traits/TestTrait.swift b/Sources/Dependencies/Traits/TestTrait.swift index 6f9bf3cf..65e98704 100644 --- a/Sources/Dependencies/Traits/TestTrait.swift +++ b/Sources/Dependencies/Traits/TestTrait.swift @@ -1,7 +1,7 @@ public struct _DependenciesTrait: Sendable { - package let updateValues: @Sendable (inout DependencyValues) -> Void + package let updateValues: @Sendable (inout DependencyValues) throws -> Void - package init(_ updateValues: @escaping @Sendable (inout DependencyValues) -> Void) { + package init(_ updateValues: @escaping @Sendable (inout DependencyValues) throws -> Void) { self.updateValues = updateValues } diff --git a/Sources/DependenciesTestSupport/TestTrait.swift b/Sources/DependenciesTestSupport/TestTrait.swift index 2ed8736f..7eaab3f7 100644 --- a/Sources/DependenciesTestSupport/TestTrait.swift +++ b/Sources/DependenciesTestSupport/TestTrait.swift @@ -43,10 +43,10 @@ /// - value: A dependency value to override for the test. public static func dependency( _ keyPath: WritableKeyPath & Sendable, - _ value: @autoclosure @escaping @Sendable () -> Value + _ value: @autoclosure @escaping @Sendable () throws -> Value ) -> Self { Self { - $0[keyPath: keyPath] = value() + $0[keyPath: keyPath] = try value() } } @@ -79,9 +79,9 @@ /// - keyPath: A key path to a dependency value. /// - value: A dependency value to override for the test. public static func dependency( - _ value: @autoclosure @escaping @Sendable () -> Value + _ value: @autoclosure @escaping @Sendable () throws -> Value ) -> Self where Value == Value.Value { - Self { $0[Value.self] = value() } + Self { $0[Value.self] = try value() } } /// A trait that overrides a test's or suite's dependencies. @@ -96,8 +96,8 @@ public var isRecursive: Bool { true } public func prepare(for test: Test) async throws { - testValuesByTestID.withValue { - self.updateValues(&$0[test.id, default: DependencyValues(context: .test)]) + try testValuesByTestID.withValue { + try self.updateValues(&$0[test.id, default: DependencyValues(context: .test)]) } } }