diff options
| author | Christian Cleberg <[email protected]> | 2026-04-12 22:52:33 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-12 22:52:33 -0500 |
| commit | 72f860e0e171f6aac4e7d896e7a571147dbcb5c5 (patch) | |
| tree | c62c9c9325292f65e6f72372a38b35760cc937b1 /HutchTests/RepositoryListViewModelTests.swift | |
| parent | 576bb6c2432a15f5138771c06019b55fd2244e15 (diff) | |
| download | hutch-72f860e0e171f6aac4e7d896e7a571147dbcb5c5.tar.gz hutch-72f860e0e171f6aac4e7d896e7a571147dbcb5c5.tar.bz2 hutch-72f860e0e171f6aac4e7d896e7a571147dbcb5c5.zip | |
feat: add search and recent queries
Implements: https://todo.sr.ht/~ccleberg/hutch/47
Implements: https://todo.sr.ht/~ccleberg/hutch/48
Diffstat (limited to 'HutchTests/RepositoryListViewModelTests.swift')
| -rw-r--r-- | HutchTests/RepositoryListViewModelTests.swift | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/HutchTests/RepositoryListViewModelTests.swift b/HutchTests/RepositoryListViewModelTests.swift index 7bd9126..07f66aa 100644 --- a/HutchTests/RepositoryListViewModelTests.swift +++ b/HutchTests/RepositoryListViewModelTests.swift @@ -29,6 +29,21 @@ struct RepositoryListViewModelTests { } @Test + @MainActor + func filterRepositoriesMatchesOwnerAndDefaultBranchLocally() { + let repositories = [ + makeRepository(id: 1, service: .git, name: "Hutch", description: nil, owner: "~alice", branch: "main"), + makeRepository(id: 2, service: .hg, name: "Mail", description: nil, owner: "~bob", branch: "stable") + ] + + let ownerMatches = RepositoryListViewModel.filterRepositories(repositories, matching: "~bob") + let branchMatches = RepositoryListViewModel.filterRepositories(repositories, matching: "main") + + #expect(ownerMatches.map(\.id) == [2]) + #expect(branchMatches.map(\.id) == [1]) + } + + @Test func buildStatusKeysParsesSourceHutRepositoryURLsFromManifest() { let manifest = """ image: alpine/latest @@ -59,7 +74,9 @@ struct RepositoryListViewModelTests { id: Int, service: SRHTService, name: String, - description: String? + description: String?, + owner: String = "~owner", + branch: String = "main" ) -> RepositorySummary { RepositorySummary( id: id, @@ -69,8 +86,8 @@ struct RepositoryListViewModelTests { description: description, visibility: .public, updated: Date(timeIntervalSince1970: TimeInterval(id)), - owner: Entity(canonicalName: "~owner"), - head: Reference(name: "main", target: nil) + owner: Entity(canonicalName: owner), + head: Reference(name: branch, target: nil) ) } } |
