cli/command/root_test.go
vilmibm f3eb092d7e isolate repo fork command and tweak usage
This commit is another isolation refactor, this time for repo fork.
However, I got fed up with the --remote="true|false|prompt" style of
flags and took this opportunity to switch to a set of bool flags:

--remote and --clone
--no-remote and --no-clone

the string args were really non standard and confusing; with only two
bools it was impossible to tell when to prompt.
2020-07-27 13:04:31 -05:00

63 lines
1.6 KiB
Go

package command
import (
"testing"
"github.com/cli/cli/internal/ghrepo"
)
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(prCheckoutCmd, ghrepo.New("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(prCheckoutCmd, ghrepo.New("OWNER", "REPO"))
eq(t, result, "git@github.com:OWNER/REPO.git")
}