Redline: timestamped result for the manual update check, update-state renders, and a duplicated-status fix (MMDB-2697) #27
@@ -0,0 +1,46 @@
|
|||||||
|
import Foundation
|
||||||
|
import Testing
|
||||||
|
@testable import Shotdeck
|
||||||
|
@testable import ShotdeckCore
|
||||||
|
|
||||||
|
@Test("DubaiTime.checkTime formats as HH:MM Dubai")
|
||||||
|
func dubaiTimeCheckTimeFormat() {
|
||||||
|
let testDate = Date(timeIntervalSince1970: 1725458520) // 2024-09-04 10:42:00 UTC
|
||||||
|
let result = DubaiTime.checkTime(testDate)
|
||||||
|
|
||||||
|
// The format should be HH:MM Dubai (24-hour time in Dubai timezone)
|
||||||
|
// Dubai is UTC+4, so a UTC time needs conversion
|
||||||
|
let pattern = "^[0-9]{2}:[0-9]{2} Dubai$"
|
||||||
|
let regex = try? NSRegularExpression(pattern: pattern, options: [])
|
||||||
|
let range = NSRange(result.startIndex..<result.endIndex, in: result)
|
||||||
|
let matches = regex?.matches(in: result, options: [], range: range) ?? []
|
||||||
|
#expect(!matches.isEmpty, "checkTime should format as HH:MM Dubai, got: \(result)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test("Status message format: 'Redline X.Y.Z is up to date, checked HH:MM Dubai'")
|
||||||
|
@MainActor
|
||||||
|
func statusMessageUpToDateFormat() {
|
||||||
|
let currentVersion = UpdateChecker.currentVersion()
|
||||||
|
let testTime = DubaiTime.checkTime(Date())
|
||||||
|
let message = "Redline \(currentVersion) is up to date, checked \(testTime)"
|
||||||
|
|
||||||
|
// Verify the format matches the expected pattern
|
||||||
|
let pattern = "^Redline [0-9]+\\.[0-9]+\\.[0-9]+ is up to date, checked [0-9]{2}:[0-9]{2} Dubai$"
|
||||||
|
let regex = try? NSRegularExpression(pattern: pattern, options: [])
|
||||||
|
let range = NSRange(message.startIndex..<message.endIndex, in: message)
|
||||||
|
let matches = regex?.matches(in: message, options: [], range: range) ?? []
|
||||||
|
#expect(!matches.isEmpty, "Message should match format, got: \(message)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test("Status message format: 'Update to X.Y.Z is ready'")
|
||||||
|
func statusMessageUpdateReadyFormat() {
|
||||||
|
let testVersion = "9.9.9"
|
||||||
|
let message = "Update to \(testVersion) is ready"
|
||||||
|
|
||||||
|
// Verify the format matches the expected pattern
|
||||||
|
let pattern = "^Update to [0-9]+\\.[0-9]+\\.[0-9]+ is ready$"
|
||||||
|
let regex = try? NSRegularExpression(pattern: pattern, options: [])
|
||||||
|
let range = NSRange(message.startIndex..<message.endIndex, in: message)
|
||||||
|
let matches = regex?.matches(in: message, options: [], range: range) ?? []
|
||||||
|
#expect(!matches.isEmpty, "Message should match format, got: \(message)")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user