Fixing tests

This commit is contained in:
Selim Mustafaev 2024-12-20 22:12:25 +03:00
parent 2481045a9c
commit 991af4a48f
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@
import Testing
import CoreLocation
import Mockable
@testable import AutoCatCore
@MainActor
@ -19,14 +20,19 @@ struct LocationServiceTests {
let geocoder = GeocoderMock()
let locationManager = SwiftLocationMock()
let settingsServiceMock = MockSettingsServiceProtocol()
let locationService: LocationService
init() {
ServiceContainer.shared.register(GeocoderProtocol.self, instance: geocoder)
ServiceContainer.shared.register(SwiftLocationProtocol.self, instance: locationManager)
ServiceContainer.shared.register(SettingsServiceProtocol.self, instance: settingsServiceMock)
self.locationService = LocationService()
given(settingsServiceMock)
.user.willReturn(User())
}
@Test

View File

@ -9,6 +9,7 @@
import Testing
import RealmSwift
import Foundation
import Mockable
@testable import AutoCatCore
@ -20,6 +21,7 @@ struct StorageServiceTests {
let testLat: Double = 42
let testLon: Double = 24
let settingsServiceMock = MockSettingsServiceProtocol()
let storageService: StorageService
init() async throws {
@ -27,9 +29,14 @@ struct StorageServiceTests {
var config: Realm.Configuration = .defaultConfiguration
config.inMemoryIdentifier = UUID().uuidString
await ServiceContainer.shared.register(SettingsServiceProtocol.self, instance: settingsServiceMock)
self.storageService = try await StorageService(config: config)
try addTestVehicle(config: config)
given(settingsServiceMock)
.user.willReturn(User())
}
func addTestVehicle(config: Realm.Configuration) throws {