native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
1.9 kB · 66 lines
Swift
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import Foundationimport Testing
@testable import supacode
@MainActorstruct WorktreeIsMainTests { @Test func identicalURLsAreMain() { let root = URL(fileURLWithPath: "/tmp/repo") let worktree = Worktree( id: "/tmp/repo", name: "main", detail: ".", workingDirectory: root, repositoryRootURL: root, ) #expect(worktree.isMain == true) }
@Test func subdirectoryWorktreeIsNotMain() { let worktree = Worktree( id: "/tmp/repo/wt-1", name: "feature", detail: "wt-1", workingDirectory: URL(fileURLWithPath: "/tmp/repo/wt-1"), repositoryRootURL: URL(fileURLWithPath: "/tmp/repo"), ) #expect(worktree.isMain == false) }
@Test func siblingWorktreeIsNotMain() { let worktree = Worktree( id: "/tmp/repo.wt/feature", name: "feature", detail: "../repo.wt/feature", workingDirectory: URL(fileURLWithPath: "/tmp/repo.wt/feature"), repositoryRootURL: URL(fileURLWithPath: "/tmp/repo"), ) #expect(worktree.isMain == false) }
@Test func dotComponentEquivalentURLsAreMain() { // `/tmp/./repo` and `/tmp/repo` are semantically the same directory. // The standardization fallback in Worktree.init covers this case even // if the caller forgot to normalize the URL beforehand. let worktree = Worktree( id: "/tmp/repo", name: "main", detail: ".", workingDirectory: URL(fileURLWithPath: "/tmp/./repo"), repositoryRootURL: URL(fileURLWithPath: "/tmp/repo"), ) #expect(worktree.isMain == true) }
@Test func dotDotComponentEquivalentURLsAreMain() { let worktree = Worktree( id: "/tmp/repo", name: "main", detail: ".", workingDirectory: URL(fileURLWithPath: "/tmp/nested/../repo"), repositoryRootURL: URL(fileURLWithPath: "/tmp/repo"), ) #expect(worktree.isMain == true) }}