Fix macOS CI tests

This commit is contained in:
Balazs Perlaki-Horvath 2025-07-13 18:02:32 +02:00
parent cdc1582acd
commit ba5b12ce54
3 changed files with 8 additions and 4 deletions

View File

@ -21,12 +21,14 @@ import Combine
@testable import Kiwix
private class HTTPTestingURLProtocol: URLProtocol {
@MainActor
static var handler: ((URLProtocol) -> Void)?
override class func canInit(with request: URLRequest) -> Bool { true }
override class func canonicalRequest(for request: URLRequest) -> URLRequest { request }
override func stopLoading() { }
@MainActor
override func startLoading() {
if let handler = HTTPTestingURLProtocol.handler {
handler(self)
@ -37,9 +39,10 @@ private class HTTPTestingURLProtocol: URLProtocol {
}
final class LibraryRefreshViewModelTest: XCTestCase {
private var urlSession: URLSession?
private var urlSession: URLSession!
private var cancellables = Set<AnyCancellable>()
@MainActor
override func setUpWithError() throws {
let config = URLSessionConfiguration.ephemeral
config.protocolClasses = [HTTPTestingURLProtocol.self]
@ -57,6 +60,7 @@ final class LibraryRefreshViewModelTest: XCTestCase {
}
}
@MainActor
override func tearDownWithError() throws {
HTTPTestingURLProtocol.handler = nil
}

View File

@ -103,12 +103,12 @@ final class LibraryViewModel: ObservableObject {
@MainActor
init(
urlSession: URLSession? = nil,
urlSession: URLSession = URLSession.shared,
processFactory: @MainActor () -> LibraryProcess = { .shared },
defaults: Defaulting = UDefaults(),
categories: CategoriesProtocol = CategoriesToLanguages(withDefaults: UDefaults())
) {
self.urlSession = urlSession ?? URLSession.shared
self.urlSession = urlSession
self.process = processFactory()
self.defaults = defaults
self.categories = categories

View File

@ -17,7 +17,7 @@ import CoreData
import SwiftUI
struct ZimFileCell: View {
@ObservedObject var zimFile: ZimFile
@MainActor @ObservedObject var zimFile: ZimFile
@State private var isHovering: Bool = false
let isLoading: Bool
let isSelected: Bool