krz/octosentry

macOS menu bar app to monitor GitHub security alerts

clone: git clone https://gitbay.org/krz/octosentry.git

1.1: octosentryTests/TestEvents.swift · raw

 1//
 2//  TestEvents.swift
 3//  octosentryTests
 4//
 5
 6import Foundation
 7@testable import octosentry
 8
 9enum TestEvents {
10    static let referenceDate = Date(timeIntervalSince1970: 1_785_000_000)
11
12    static func event(
13        id: String,
14        source: SecurityEventSource = .dependabot,
15        repo: String = "octocat/hello-world",
16        severity: SecurityEventSeverity = .high,
17        summary: String = "A summary",
18        ageInHours: Double = 0
19    ) -> SecurityEvent {
20        let createdAt = referenceDate.addingTimeInterval(-ageInHours * 3600)
21        return SecurityEvent(
22            id: id,
23            source: source,
24            repoFullName: repo,
25            severity: severity,
26            nativeSeverityLabel: severity.displayName,
27            summary: summary,
28            detailURL: URL(string: "https://github.com/\(repo)/security/\(id)")!,
29            createdAt: createdAt,
30            updatedAt: createdAt,
31            seenLocally: false
32        )
33    }
34}