mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-08 11:46:25 -04:00
Fix macOS CI tests
This commit is contained in:
parent
cdc1582acd
commit
ba5b12ce54
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user