diff options
Diffstat (limited to 'HutchTests/ProjectTests.swift')
| -rw-r--r-- | HutchTests/ProjectTests.swift | 135 |
1 files changed, 72 insertions, 63 deletions
diff --git a/HutchTests/ProjectTests.swift b/HutchTests/ProjectTests.swift index eff800f..0323f25 100644 --- a/HutchTests/ProjectTests.swift +++ b/HutchTests/ProjectTests.swift @@ -3,52 +3,61 @@ import Testing @testable import Hutch struct ProjectTests { + private enum Fixture { + static let exampleWebsite = "https://example.com" + } + @Test func resourceSummaryIncludesCounts() { let project = Project( - id: "project-1", - name: "Hutch", - description: nil, - website: nil, - visibility: .public, - tags: [], - updated: Date(timeIntervalSince1970: 0), - mailingLists: [ - Project.MailingList( - id: "list-1", - name: "hutch-devel", - description: nil, - visibility: .public, - owner: Entity(canonicalName: "~owner") - ) - ], - sources: [ - Project.SourceRepo( - id: "repo-1", - name: "hutch", - description: nil, - visibility: .public, - owner: Entity(canonicalName: "~owner"), - repoType: .git - ), - Project.SourceRepo( - id: "repo-2", - name: "hutch-web", - description: nil, - visibility: .public, - owner: Entity(canonicalName: "~owner"), - repoType: .git - ) - ], - trackers: [ - Project.Tracker( - id: "tracker-1", - name: "bugs", - description: nil, - visibility: .public, - owner: Entity(canonicalName: "~owner") - ) - ] + metadata: .init( + id: "project-1", + name: "Hutch", + description: nil, + website: nil, + visibility: .public, + tags: [], + updated: Date(timeIntervalSince1970: 0) + ), + resources: .init( + mailingLists: [ + Project.MailingList( + id: "list-1", + name: "hutch-devel", + description: nil, + visibility: .public, + owner: Entity(canonicalName: "~owner") + ) + ], + sources: [ + Project.SourceRepo( + id: "repo-1", + name: "hutch", + description: nil, + visibility: .public, + owner: Entity(canonicalName: "~owner"), + repoType: .git + ), + Project.SourceRepo( + id: "repo-2", + name: "hutch-web", + description: nil, + visibility: .public, + owner: Entity(canonicalName: "~owner"), + repoType: .git + ) + ], + trackers: [ + Project.Tracker( + id: "tracker-1", + name: "bugs", + description: nil, + visibility: .public, + owner: Entity(canonicalName: "~owner") + ) + ], + isFullyLoaded: true + ) ) #expect(project.resourceSummary == "2 repos • 1 tracker • 1 list") @@ -57,16 +66,16 @@ struct ProjectTests { @Test func resourceSummaryFallsBackToWebsite() { let project = Project( - id: "project-1", - name: "Docs", - description: nil, - website: "https://example.com", - visibility: .public, - tags: [], - updated: Date(timeIntervalSince1970: 0), - mailingLists: [], - sources: [], - trackers: [] + metadata: .init( + id: "project-1", + name: "Docs", + description: nil, + website: Fixture.exampleWebsite, + visibility: .public, + tags: [], + updated: Date(timeIntervalSince1970: 0) + ), + resources: .init(mailingLists: [], sources: [], trackers: [], isFullyLoaded: true) ) #expect(project.resourceSummary == "Website linked") @@ -75,16 +84,16 @@ struct ProjectTests { @Test func displayHelpersNormalizeBlankValues() { let project = Project( - id: "project-1", - name: " ", - description: "\n", - website: "https://example.com", - visibility: .unlisted, - tags: [" docs ", "", "Docs", "ios"], - updated: Date(timeIntervalSince1970: 0), - mailingLists: [], - sources: [], - trackers: [] + metadata: .init( + id: "project-1", + name: " ", + description: "\n", + website: Fixture.exampleWebsite, + visibility: .unlisted, + tags: [" docs ", "", "Docs", "ios"], + updated: Date(timeIntervalSince1970: 0) + ), + resources: .init(mailingLists: [], sources: [], trackers: [], isFullyLoaded: true) ) #expect(project.displayName == "Untitled Project") |
