native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
1.6 kB · 36 lines
Swift
12345678910111213141516171819202122232425262728293031323334353637import Foundationimport Testing
@testable import supacode
struct CloneRepositoryViewTests { @Test func cloneRequestTrimsURLAndNormalizesDestinationPath() { let request = CloneRepositoryView.cloneRequest( urlString: " https://github.com/onevcat/Prowl.git \n", locationPath: " ~/Developer " )
let expectedPath = FileManager.default.homeDirectoryForCurrentUser .appending(path: "Developer", directoryHint: .isDirectory) .appending(path: "Prowl", directoryHint: .isDirectory) .standardizedFileURL .path(percentEncoded: false)
#expect(request?.url == "https://github.com/onevcat/Prowl.git") #expect(request?.destination.path(percentEncoded: false) == expectedPath) }
@Test func extractRepoNameHandlesCommonGitURLForms() { #expect(CloneRepositoryView.extractRepoName(from: "git@github.com:onevcat/Prowl.git") == "Prowl") #expect(CloneRepositoryView.extractRepoName(from: "git@github.com:Prowl.git") == "Prowl") #expect(CloneRepositoryView.extractRepoName(from: "https://github.com/onevcat/Prowl.git?ref=main") == "Prowl") #expect(CloneRepositoryView.extractRepoName(from: " https://github.com/onevcat/Prowl.git/ ") == "Prowl") }
@Test func isGitURLTrimsClipboardContentAndRequiresKnownHostsForHTTPURLs() { #expect(CloneRepositoryView.isGitURL(" https://github.com/onevcat/Prowl \n")) #expect(CloneRepositoryView.isGitURL("git@github.com:onevcat/Prowl.git")) #expect(CloneRepositoryView.isGitURL("ssh://git@example.com/onevcat/Prowl.git")) #expect(!CloneRepositoryView.isGitURL("https://github.com.evil/onevcat/Prowl")) }}