summaryrefslogtreecommitdiff
path: root/HutchTests
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-08-07 04:19:04 -0500
committerGitHub <[email protected]>2026-08-07 04:19:04 -0500
commit3ae35daa9495b9b1e01f1063bd05c636b97fd927 (patch)
tree25cf810fa0e9a0ab343b60b59c26d8cc096c9a98 /HutchTests
parentdb40d346c28800a1eec384a5e4f3d7d090198e4d (diff)
parent1f8f651a9c2ac2d6be231ff9f71ee3bcce9936d8 (diff)
downloadhutch-3ae35daa9495b9b1e01f1063bd05c636b97fd927.tar.gz
hutch-3ae35daa9495b9b1e01f1063bd05c636b97fd927.tar.bz2
hutch-3ae35daa9495b9b1e01f1063bd05c636b97fd927.zip
Merge pull request #33 from krazywarez/projects-crud
Projects: discovery, create, edit, manage linked resources (#12, #13, #14, #15)
Diffstat (limited to 'HutchTests')
-rw-r--r--HutchTests/ProjectFormTests.swift39
1 files changed, 39 insertions, 0 deletions
diff --git a/HutchTests/ProjectFormTests.swift b/HutchTests/ProjectFormTests.swift
new file mode 100644
index 0000000..a4b4dfa
--- /dev/null
+++ b/HutchTests/ProjectFormTests.swift
@@ -0,0 +1,39 @@
+import Foundation
+import Testing
+@testable import Hutch
+
+struct ProjectFormTests {
+ @Test
+ func parsesTagsSplittingAndTrimming() {
+ #expect(ProjectFormSheet.parseTags("swift, ios , ") == ["swift", "ios"])
+ #expect(ProjectFormSheet.parseTags("a,b,c") == ["a", "b", "c"])
+ }
+
+ @Test
+ func parseTagsDeduplicatesCaseInsensitively() {
+ #expect(ProjectFormSheet.parseTags("Swift, swift, SWIFT") == ["Swift"])
+ }
+
+ @Test
+ func parseTagsEmptyInputYieldsEmpty() {
+ #expect(ProjectFormSheet.parseTags(" ").isEmpty)
+ #expect(ProjectFormSheet.parseTags("").isEmpty)
+ }
+
+ @Test
+ func linkableResourceDisplayNameCombinesOwnerAndName() {
+ let resource = LinkableResource(rid: "r1", name: "hutch", ownerCanonicalName: "~alice", kind: .source)
+ #expect(resource.displayName == "~alice/hutch")
+ #expect(resource.id == "r1")
+ }
+
+ @Test
+ func discoveredProjectIDMatchesProject() {
+ let project = Project(
+ metadata: .init(id: "p1", name: "Hutch", description: nil, website: nil, visibility: .publicVisibility, tags: [], updated: .now),
+ resources: .init(mailingLists: [], sources: [], trackers: [], isFullyLoaded: false)
+ )
+ let discovered = DiscoveredProject(project: project, ownerCanonicalName: "~alice")
+ #expect(discovered.id == "p1")
+ }
+}