Fixing tests

This commit is contained in:
Selim Mustafaev 2025-04-04 17:50:16 +03:00
parent 49a7e88ee5
commit 371a2ebdb6

View File

@ -8,13 +8,14 @@
import Testing import Testing
import Mockable import Mockable
import AutoCatCore @testable import AutoCatCore
import Foundation
struct VehicleRecordServiceTests { struct VehicleRecordServiceTests {
let storageServiceMock = MockStorageServiceProtocol()
let locationServiceMock: MockLocationServiceProtocol let locationServiceMock: MockLocationServiceProtocol
let audioRecordServiceMock = MockAudioRecordServiceProtocol() let audioRecordServiceMock = MockAudioRecordServiceProtocol()
let settingsServiceMock = MockSettingsServiceProtocol()
let vehicleRecordService: VehicleRecordService let vehicleRecordService: VehicleRecordService
init() async { init() async {
@ -23,8 +24,8 @@ struct VehicleRecordServiceTests {
self.vehicleRecordService = .init( self.vehicleRecordService = .init(
recordService: audioRecordServiceMock, recordService: audioRecordServiceMock,
storageService: storageServiceMock, locationService: locationServiceMock,
locationService: locationServiceMock settingsService: settingsServiceMock
) )
} }
@ -50,5 +51,29 @@ struct VehicleRecordServiceTests {
.called(.once) .called(.once)
} }
@Test("Start recording")
func startRecording() async throws {
given(audioRecordServiceMock)
.startRecording(to: .any)
.willReturn()
given(locationServiceMock)
.getRecentLocation()
.willReturn(.valid)
try await vehicleRecordService.startRecording()
verify(audioRecordServiceMock)
.startRecording(to: .any)
.called(.once)
verify(locationServiceMock)
.getRecentLocation()
.called(.once)
await #expect(vehicleRecordService.url != nil)
await #expect(vehicleRecordService.location != nil)
await #expect(vehicleRecordService.locationTask != nil)
}
} }