Skip to content

Commit

Permalink
🧪 RecordingJourneyStorage 변경에 따른 유닛테스트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftyJunnos committed Jan 10, 2024
1 parent 20c1280 commit bae2e0d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions iOS/MSData/Tests/RepositoryTests/PersistentManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@ final class PersistentManagerTests: XCTestCase {

// MARK: - Properties

let storage = FileManagerStorage()
private let storage = FileManagerStorage()
private var recordingJourney = RecordingJourneyStorage.shared

override func tearDown() async throws {
try self.recordingJourney.finish()
}

// MARK: - Tests

func test_Spot저장_성공() {
let coordinate = Coordinate(latitude: 10, longitude: 10)
let url = URL(string: "/../")!

let spot = Spot(coordinate: coordinate, timestamp: .now, photoURL: url)
self.recordingJourney.start(initialData: RecordingJourney(id: UUID().uuidString,
startTimestamp: .now,
spots: [],
coordinates: []))

XCTAssertTrue(RecordingJourneyStorage.shared.record(SpotDTO(spot), at: self.storage))
}

func test_RecordingJourney_하위요소가_아닌_것들_저장_실패() {
XCTAssertFalse(RecordingJourneyStorage.shared.record(Int(), at: self.storage))
let spot = Spot(coordinate: coordinate, timestamp: .now, photoURL: url)
XCTAssertTrue(self.recordingJourney.record([SpotDTO(spot)], keyPath: \.spots))
}

func test_RecordingJourney_반환_성공() {
Expand All @@ -39,12 +44,14 @@ final class PersistentManagerTests: XCTestCase {
let coordinate = Coordinate(latitude: 5, longitude: 5)
let spot = Spot(coordinate: coordinate, timestamp: .now, photoURL: url)

RecordingJourneyStorage.shared.record(id, at: self.storage)
RecordingJourneyStorage.shared.record(Date.now, at: self.storage)
RecordingJourneyStorage.shared.record(SpotDTO(spot), at: self.storage)
RecordingJourneyStorage.shared.record(CoordinateDTO(coordinate), at: self.storage)
self.recordingJourney.start(initialData: RecordingJourney(id: id,
startTimestamp: startTimestamp,
spots: [],
coordinates: []))
self.recordingJourney.record([SpotDTO(spot)], keyPath: \.spots)
self.recordingJourney.record([CoordinateDTO(coordinate)], keyPath: \.coordinates)

guard let loadedJourney = RecordingJourneyStorage.shared.loadJourney(from: self.storage) else {
guard let loadedJourney = self.recordingJourney.currentState else {
XCTFail("load 실패")
return
}
Expand Down

0 comments on commit bae2e0d

Please sign in to comment.