mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Unit Tests migration to swift 6.2 (#5781)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
@testable import ElementX
|
||||
import Foundation
|
||||
import Synchronization
|
||||
import Testing
|
||||
|
||||
final class ClassicAppMediaLoaderTests {
|
||||
@@ -126,7 +127,7 @@ final class ClassicAppMediaLoaderTests {
|
||||
|
||||
// MARK: - MockURLProtocol
|
||||
|
||||
private class MockURLProtocol: URLProtocol {
|
||||
private nonisolated class MockURLProtocol: URLProtocol {
|
||||
/// The MXC URL whose media requests will be served successfully.
|
||||
static let mxcURL: URL = "mxc://matrix.org/testmediaid"
|
||||
/// The MXC URL whose media requests will return a 404.
|
||||
@@ -141,7 +142,10 @@ private class MockURLProtocol: URLProtocol {
|
||||
static let thumbnailData = Data("thumbnail data".utf8)
|
||||
|
||||
/// The last request handled, for URL/header inspection in tests.
|
||||
static var lastRequest: URLRequest?
|
||||
private static let _lastRequest: Mutex<URLRequest?> = .init(nil)
|
||||
static var lastRequest: URLRequest? {
|
||||
_lastRequest.withLock { $0 }
|
||||
}
|
||||
|
||||
/// Maps a URL path to a fixed `(statusCode, Data)` response.
|
||||
private static let responses: [String: (Int, Data)] = [
|
||||
@@ -150,7 +154,7 @@ private class MockURLProtocol: URLProtocol {
|
||||
]
|
||||
|
||||
override func startLoading() {
|
||||
MockURLProtocol.lastRequest = request
|
||||
MockURLProtocol._lastRequest.withLock { $0 = request }
|
||||
|
||||
guard let url = request.url else {
|
||||
client?.urlProtocol(self, didFailWithError: URLError(.badURL))
|
||||
|
||||
Reference in New Issue
Block a user