Created
September 5, 2025 21:59
-
-
Save jubishop/b0873ba098807e139e1712816cd6f8d0 to your computer and use it in GitHub Desktop.
Staged changes in PodHaven FakeFileManager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/PodHavenTests/Fakes/FakeFileManager.swift b/PodHavenTests/Fakes/FakeFileManager.swift | |
| index 5d001e2..96972bb 100644 | |
| --- a/PodHavenTests/Fakes/FakeFileManager.swift | |
| +++ b/PodHavenTests/Fakes/FakeFileManager.swift | |
| @@ -3,115 +3,61 @@ | |
| import Foundation | |
| @testable import PodHaven | |
| final class FakeFileManager: FileManageable, @unchecked Sendable { | |
| // MARK: - State | |
| private let inMemoryFiles = ThreadSafe<[URL: Data]>([:])\n- private let inMemoryDirectories = ThreadSafe<Set<URL>>([]) // TODO: why do i need this? | |
| // MARK: - Initialization | |
| init() {} | |
| // MARK: - Data Operations | |
| func writeData(_ data: Data, to url: URL) async throws { | |
| - // Ensure parent directories exist | |
| - let parentURL = url.deletingLastPathComponent() | |
| - if parentURL != url { // Prevent infinite recursion for root | |
| - inMemoryDirectories { $0.insert(parentURL) } | |
| - } | |
| - | |
| inMemoryFiles { $0[url] = data } | |
| } | |
| func readData(from url: URL) async throws -> Data { | |
| - if let data = inMemoryFiles({ $0[url] }) { | |
| - return data | |
| - } | |
| - throw TestError.fileNotFound(url) | |
| + guard let data = inMemoryFiles({ $0[url] }) | |
| + else { throw TestError.fileNotFound(url) } | |
| + | |
| + return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment