krz/hutch

an ios client for sourcehut

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

v2.5.2: HutchTests/ProjectTests.swift · raw

 1import Foundation
 2import Testing
 3@testable import Hutch
 4
 5struct ProjectTests {
 6    @Test
 7    func resourceSummaryIncludesCounts() {
 8        let project = Project(
 9            id: "project-1",
10            name: "Hutch",
11            description: nil,
12            website: nil,
13            visibility: .public,
14            tags: [],
15            mailingLists: [
16                Project.MailingList(
17                    id: "list-1",
18                    name: "hutch-devel",
19                    description: nil,
20                    visibility: .public,
21                    owner: Entity(canonicalName: "~owner")
22                )
23            ],
24            sources: [
25                Project.SourceRepo(
26                    id: "repo-1",
27                    name: "hutch",
28                    description: nil,
29                    visibility: .public,
30                    owner: Entity(canonicalName: "~owner"),
31                    repoType: .git
32                ),
33                Project.SourceRepo(
34                    id: "repo-2",
35                    name: "hutch-web",
36                    description: nil,
37                    visibility: .public,
38                    owner: Entity(canonicalName: "~owner"),
39                    repoType: .git
40                )
41            ],
42            trackers: [
43                Project.Tracker(
44                    id: "tracker-1",
45                    name: "bugs",
46                    description: nil,
47                    visibility: .public,
48                    owner: Entity(canonicalName: "~owner")
49                )
50            ]
51        )
52
53        #expect(project.resourceSummary == "2 repos • 1 tracker • 1 list")
54    }
55
56    @Test
57    func resourceSummaryFallsBackToWebsite() {
58        let project = Project(
59            id: "project-1",
60            name: "Docs",
61            description: nil,
62            website: "https://example.com",
63            visibility: .public,
64            tags: [],
65            mailingLists: [],
66            sources: [],
67            trackers: []
68        )
69
70        #expect(project.resourceSummary == "Website linked")
71    }
72}