Skip to content

Commit 32ed34b

Browse files
jasonlongclaude
andcommitted
Fix test fixtures using hardcoded dates that expire after 14 days
Dependabot alert tests used a fixed 2026-04-01 timestamp that fell outside the 14-day lookback window after April 15. Replace with dynamic dates relative to now so tests never expire. Also update PanelInput dedup interval assertion to match the new 50ms value. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ed7b69f commit 32ed34b

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

OctodotTests/AppStateTests.swift

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ import Testing
44

55
@MainActor
66
struct AppStateTests {
7+
static let recentDateString: String = {
8+
let formatter = ISO8601DateFormatter()
9+
return formatter.string(from: Date().addingTimeInterval(-2 * 24 * 60 * 60))
10+
}()
11+
12+
static let recentUpdatedDateString: String = {
13+
let formatter = ISO8601DateFormatter()
14+
return formatter.string(from: Date().addingTimeInterval(-1 * 24 * 60 * 60))
15+
}()
16+
717
static func makeNotification(id: Int, repo: String = "acme/alpha", isUnread: Bool = true) -> GitHubNotification {
818
GitHubNotification(
919
id: "\(id)",
@@ -98,7 +108,7 @@ struct AppStateTests {
98108
static func singleNotificationPayload(
99109
id: String,
100110
isUnread: Bool = true,
101-
updatedAt: String = "2026-04-01T12:00:00Z",
111+
updatedAt: String = recentDateString,
102112
subjectURL: String? = nil
103113
) -> Data {
104114
let subjectURLField: String
@@ -129,7 +139,7 @@ struct AppStateTests {
129139
""".data(using: .utf8)!
130140
}
131141

132-
static func notificationsPayload(ids: [String], updatedAt: String = "2026-04-01T12:00:00Z") -> Data {
142+
static func notificationsPayload(ids: [String], updatedAt: String = recentDateString) -> Data {
133143
let items = ids.map { id in
134144
"""
135145
{
@@ -153,7 +163,7 @@ struct AppStateTests {
153163
return "[\n\(items)\n]".data(using: .utf8)!
154164
}
155165

156-
static func dependabotAlertsPayload(updatedAt: String = "2026-04-01T12:00:00Z") -> Data {
166+
static func dependabotAlertsPayload(updatedAt: String = recentDateString) -> Data {
157167
"""
158168
[
159169
{
@@ -465,7 +475,7 @@ struct AppStateTests {
465475
)
466476
)),
467477
.success((
468-
Self.dependabotAlertsPayload(updatedAt: "2026-04-01T12:00:00Z"),
478+
Self.dependabotAlertsPayload(),
469479
Self.httpResponse(
470480
url: "https://api.github.com/repos/acme/alpha/dependabot/alerts",
471481
statusCode: 200
@@ -487,7 +497,7 @@ struct AppStateTests {
487497
)
488498
)),
489499
.success((
490-
Self.dependabotAlertsPayload(updatedAt: "2026-04-01T12:00:00Z"),
500+
Self.dependabotAlertsPayload(),
491501
Self.httpResponse(
492502
url: "https://api.github.com/repos/acme/alpha/dependabot/alerts",
493503
statusCode: 200
@@ -509,7 +519,7 @@ struct AppStateTests {
509519
)
510520
)),
511521
.success((
512-
Self.dependabotAlertsPayload(updatedAt: "2026-04-02T12:00:00Z"),
522+
Self.dependabotAlertsPayload(updatedAt: Self.recentUpdatedDateString),
513523
Self.httpResponse(
514524
url: "https://api.github.com/repos/acme/alpha/dependabot/alerts",
515525
statusCode: 200
@@ -576,7 +586,7 @@ struct AppStateTests {
576586
)
577587
)),
578588
.success((
579-
Self.dependabotAlertsPayload(updatedAt: "2026-04-01T12:00:00Z"),
589+
Self.dependabotAlertsPayload(),
580590
Self.httpResponse(
581591
url: "https://api.github.com/repos/acme/alpha/dependabot/alerts",
582592
statusCode: 200
@@ -628,7 +638,7 @@ struct AppStateTests {
628638
)
629639
)),
630640
.success((
631-
Self.dependabotAlertsPayload(updatedAt: "2026-04-01T12:00:00Z"),
641+
Self.dependabotAlertsPayload(),
632642
Self.httpResponse(
633643
url: "https://api.github.com/repos/acme/alpha/dependabot/alerts",
634644
statusCode: 200
@@ -650,7 +660,7 @@ struct AppStateTests {
650660
)
651661
)),
652662
.success((
653-
Self.dependabotAlertsPayload(updatedAt: "2026-04-01T12:00:00Z"),
663+
Self.dependabotAlertsPayload(),
654664
Self.httpResponse(
655665
url: "https://api.github.com/repos/acme/alpha/dependabot/alerts",
656666
statusCode: 200

OctodotTests/GitHubAPIClientTests.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import Testing
33
@testable import Octodot
44

55
struct GitHubAPIClientTests {
6+
private static let recentDateString: String = {
7+
let formatter = ISO8601DateFormatter()
8+
return formatter.string(from: Date().addingTimeInterval(-2 * 24 * 60 * 60))
9+
}()
10+
611
private struct NotificationFixture {
712
let id: String
813
let unread: Bool
@@ -48,7 +53,7 @@ struct GitHubAPIClientTests {
4853
repositoryHTMLURL: String,
4954
summary: String,
5055
ghsaID: String,
51-
updatedAt: String = "2026-04-01T12:00:00Z"
56+
updatedAt: String = recentDateString
5257
) {
5358
self.number = number
5459
self.repositoryFullName = repositoryFullName
@@ -661,8 +666,7 @@ struct GitHubAPIClientTests {
661666
repositoryFullName: "acme/api",
662667
repositoryHTMLURL: "https://github.com/acme/api",
663668
summary: "Recent electron issue",
664-
ghsaID: "GHSA-1234",
665-
updatedAt: "2026-04-01T12:00:00Z"
669+
ghsaID: "GHSA-1234"
666670
),
667671
DependabotAlertFixture(
668672
number: 8,

OctodotTests/PanelContentViewTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,6 @@ struct PanelContentViewTests {
143143
#expect(PanelInput.isSingleFireListCommand(.moveDown) == false)
144144
#expect(PanelInput.isSingleFireListCommand(.moveUp) == false)
145145
#expect(PanelInput.isSingleFireListCommand(.forceRefresh) == false)
146-
#expect(PanelInput.singleFireCommandDeduplicationInterval == 0.2)
146+
#expect(PanelInput.singleFireCommandDeduplicationInterval == 0.05)
147147
}
148148
}

0 commit comments

Comments
 (0)