HealthProbe / HealthProbeTests / LocalOperationLogTests.swift
Newer Older
35 lines | 1.059kb
Bogdan Timofte authored 2 weeks ago
1
import XCTest
2
@testable import HealthProbe
3

            
4
final class LocalOperationLogTests: XCTestCase {
5
    override func tearDown() {
6
        LocalOperationLogStore.removeAll()
7
        super.tearDown()
8
    }
9

            
10
    func testAppendsLogsNewestFirst() {
11
        var older = LocalOperationLog(
12
            operationType: "delete",
13
            summary: "Older",
14
            deviceID: "device-a",
15
            appBuildVersion: "1"
16
        )
17
        older.timestamp = Date(timeIntervalSince1970: 1)
18

            
19
        var newer = LocalOperationLog(
20
            operationType: "delete",
21
            summary: "Newer",
22
            deviceID: "device-a",
23
            appBuildVersion: "1"
24
        )
25
        newer.timestamp = Date(timeIntervalSince1970: 2)
26
        newer.affectedSnapshotIDs = ["snapshot-a"]
27

            
28
        LocalOperationLogStore.append(older)
29
        LocalOperationLogStore.append(newer)
30

            
31
        let logs = LocalOperationLogStore.allLogs()
32
        XCTAssertEqual(logs.map(\.summary), ["Newer", "Older"])
33
        XCTAssertEqual(logs.first?.affectedSnapshotIDs, ["snapshot-a"])
34
    }
35
}