cli/command/root_test.go
Mislav Marohnić 7b28605e6f Fix current changelog link in gh version
Also allow pre-release tags.
2020-01-28 18:31:12 +01:00

36 lines
940 B
Go

package command
import (
"fmt"
"testing"
)
func TestChangelogURL(t *testing.T) {
tag := "0.3.2"
url := fmt.Sprintf("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 = fmt.Sprintf("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 = fmt.Sprintf("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 = fmt.Sprintf("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)
}
}