Previously, the version string didn't match the `vX.Y.Z` pattern because the wrong variable was passed to `changelogURL`.
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
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 = "v0.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)
|
|
}
|
|
}
|