this adds recognition of the git_protocol setting when: - creating a repo - cloning a repo - forking a repo - forking/pushing during pr create - checking out a PR additionally, it: - consolidates remote adding to use AddRemote; this introduces a fetch where there previously hadn't been one - changes repo clone to accept an ssh url - changes repo fork to accept an ssh url i just added basic unit tests; adding new test cases for all of the above scenarios seemed like diminishing returns.
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package command
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestChangelogURL(t *testing.T) {
|
|
tag := "0.3.2"
|
|
url := "https://github.com/cli/cli/releases/tag/v0.3.2"
|
|
result := changelogURL(tag)
|
|
if result != url {
|
|
t.Errorf("expected %s to create url %s but got %s", tag, url, result)
|
|
}
|
|
|
|
tag = "v0.3.2"
|
|
url = "https://github.com/cli/cli/releases/tag/v0.3.2"
|
|
result = changelogURL(tag)
|
|
if result != url {
|
|
t.Errorf("expected %s to create url %s but got %s", tag, url, result)
|
|
}
|
|
|
|
tag = "0.3.2-pre.1"
|
|
url = "https://github.com/cli/cli/releases/tag/v0.3.2-pre.1"
|
|
result = changelogURL(tag)
|
|
if result != url {
|
|
t.Errorf("expected %s to create url %s but got %s", tag, url, result)
|
|
}
|
|
|
|
tag = "0.3.5-90-gdd3f0e0"
|
|
url = "https://github.com/cli/cli/releases/latest"
|
|
result = changelogURL(tag)
|
|
if result != url {
|
|
t.Errorf("expected %s to create url %s but got %s", tag, url, result)
|
|
}
|
|
|
|
tag = "deadbeef"
|
|
url = "https://github.com/cli/cli/releases/latest"
|
|
result = changelogURL(tag)
|
|
if result != url {
|
|
t.Errorf("expected %s to create url %s but got %s", tag, url, result)
|
|
}
|
|
}
|
|
|
|
func TestRemoteURLFormatting_no_config(t *testing.T) {
|
|
initBlankContext("", "OWNER/REPO", "master")
|
|
result := formatRemoteURL(repoForkCmd, "OWNER/REPO")
|
|
eq(t, result, "https://github.com/OWNER/REPO.git")
|
|
}
|
|
|
|
func TestRemoteURLFormatting_ssh_config(t *testing.T) {
|
|
cfg := `---
|
|
hosts:
|
|
github.com:
|
|
user: OWNER
|
|
oauth_token: MUSTBEHIGHCUZIMATOKEN
|
|
git_protocol: ssh
|
|
`
|
|
initBlankContext(cfg, "OWNER/REPO", "master")
|
|
result := formatRemoteURL(repoForkCmd, "OWNER/REPO")
|
|
eq(t, result, "git@github.com:OWNER/REPO.git")
|
|
}
|