diff options
| author | Christian Cleberg <[email protected]> | 2026-04-23 17:39:13 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-23 17:39:13 -0500 |
| commit | 66601a8091a73f3e31f4fb534c38b3eca4756e93 (patch) | |
| tree | f85cd883e63177d25dfe5993a4d545efa4812923 /HutchTests/BuildListViewModelTests.swift | |
| parent | 380fb866d090c5f13b2ad3f88f1fe23c4ade4801 (diff) | |
| download | hutch-66601a8091a73f3e31f4fb534c38b3eca4756e93.tar.gz hutch-66601a8091a73f3e31f4fb534c38b3eca4756e93.tar.bz2 hutch-66601a8091a73f3e31f4fb534c38b3eca4756e93.zip | |
fix: profile loading error and user-timeline prefs updatev3.2.1
Diffstat (limited to 'HutchTests/BuildListViewModelTests.swift')
| -rw-r--r-- | HutchTests/BuildListViewModelTests.swift | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/HutchTests/BuildListViewModelTests.swift b/HutchTests/BuildListViewModelTests.swift index fccd7cf..aa2e46b 100644 --- a/HutchTests/BuildListViewModelTests.swift +++ b/HutchTests/BuildListViewModelTests.swift @@ -49,22 +49,70 @@ struct BuildListViewModelTests { makeJob(id: 4, status: .cancelled, tags: []) ] - let attention = BuildListViewModel.filterJobs(jobs, filter: .attention) - let active = BuildListViewModel.filterJobs(jobs, filter: .active) + let attention = BuildListViewModel.filterJobs( + jobs, + filter: .attention, + lookbackDays: BuildListViewModel.defaultLookbackDays + ) + let active = BuildListViewModel.filterJobs( + jobs, + filter: .active, + lookbackDays: BuildListViewModel.defaultLookbackDays + ) #expect(attention.map(\.id) == [2, 3]) #expect(active.map(\.id) == [3]) } + @Test + func buildFilterRestrictsJobsToSelectedLookbackWindow() { + let now = Date(timeIntervalSince1970: 60 * 60 * 24 * 20) + let jobs = [ + makeJob( + id: 1, + status: .failed, + tags: [], + updated: now.addingTimeInterval(-(60 * 60 * 24)) + ), + makeJob( + id: 2, + status: .running, + tags: [], + updated: now.addingTimeInterval(-(60 * 60 * 24 * 8)) + ), + makeJob( + id: 3, + status: .success, + tags: [], + updated: now.addingTimeInterval(-(60 * 60 * 24 * 2)) + ), + ] + + let filtered = BuildListViewModel.filterJobs( + jobs, + filter: .all, + lookbackDays: 3, + now: now, + calendar: Calendar(identifier: .gregorian) + ) + + #expect(filtered.map(\.id) == [1, 3]) + } + private func filterJobs(_ jobs: [JobSummary], query: String) -> [JobSummary] { BuildListViewModel.searchJobs(jobs, matching: query) } - private func makeJob(id: Int, status: JobStatus = .success, tags: [String]) -> JobSummary { + private func makeJob( + id: Int, + status: JobStatus = .success, + tags: [String], + updated: Date = Date() + ) -> JobSummary { JobSummary( id: id, - created: Date(), - updated: Date(), + created: updated, + updated: updated, status: status, note: nil, tags: tags, |
