Unit Tests migration to swift 6.2 (#5781)

This commit is contained in:
Mauro
2026-06-24 12:39:35 +02:00
committed by GitHub
parent c5cf9e2fac
commit c93d6e3265
20 changed files with 99 additions and 90 deletions
@@ -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))