-
-
Save thexande/c50915f46a079f06ee3266eca9d2349c to your computer and use it in GitHub Desktop.
This file contains 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
import XCTest | |
@testable import Apollo | |
protocol TestCacheProvider: AnyObject { | |
static func withCache(initialRecords: RecordSet?, | |
execute test: (NormalizedCache) throws -> ()) rethrows | |
} | |
final class InMemoryTestCacheProvider: TestCacheProvider { | |
/// Execute a test block rather than return a cache synchronously, since cache setup may be | |
/// asynchronous at some point. | |
static func withCache(initialRecords: RecordSet? = nil, | |
execute test: (NormalizedCache) throws -> ()) rethrows { | |
let cache = InMemoryNormalizedCache(records: initialRecords ?? [:]) | |
try test(cache) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment