native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
1.2 kB · 34 lines
Swift
1234567891011121314151617181920212223242526272829303132333435import Dependenciesimport Foundation
/// Dependency wrapper around `RepositoryIconDetector` so reducer tests/// can substitute fixture candidates without touching the file system.nonisolated struct RepositoryIconDetectorClient: Sendable { var detect: @Sendable (_ rootURL: URL) async -> RepositoryIconCandidate?}
nonisolated enum RepositoryIconDetectorClientKey: DependencyKey { static var liveValue: RepositoryIconDetectorClient { RepositoryIconDetectorClient( detect: { rootURL in await RepositoryIconDetector.detect(at: rootURL) } ) }
/// Detection is opportunistic; "found nothing" is the safe default /// for previews and for tests that don't care about icons. static var previewValue: RepositoryIconDetectorClient { RepositoryIconDetectorClient(detect: { _ in nil }) } static var testValue: RepositoryIconDetectorClient { RepositoryIconDetectorClient(detect: { _ in nil }) }}
extension DependencyValues { nonisolated var repositoryIconDetector: RepositoryIconDetectorClient { get { self[RepositoryIconDetectorClientKey.self] } set { self[RepositoryIconDetectorClientKey.self] = newValue } }}