mirror of
https://github.com/MedzikUser/go-github-selfupdate.git
synced 2024-08-15 03:25:29 +00:00
fix tests for checking prefix of tag name
This commit is contained in:
parent
f6766d9880
commit
68bce0b4e5
1 changed files with 15 additions and 12 deletions
|
@ -51,20 +51,23 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDetectReleasesForVariousArchives(t *testing.T) {
|
func TestDetectReleasesForVariousArchives(t *testing.T) {
|
||||||
for _, repo := range []string{
|
for _, tc := range []struct {
|
||||||
"rhysd-test/test-release-zip",
|
slug string
|
||||||
"rhysd-test/test-release-tar",
|
prefix string
|
||||||
"rhysd-test/test-release-gzip",
|
}{
|
||||||
"rhysd-test/test-release-xz",
|
{"rhysd-test/test-release-zip", "v"},
|
||||||
"rhysd-test/test-release-tar-xz",
|
{"rhysd-test/test-release-tar", "v"},
|
||||||
|
{"rhysd-test/test-release-gzip", "v"},
|
||||||
|
{"rhysd-test/test-release-xz", "release-v"},
|
||||||
|
{"rhysd-test/test-release-tar-xz", "release-"},
|
||||||
} {
|
} {
|
||||||
t.Run(repo, func(t *testing.T) {
|
t.Run(tc.slug, func(t *testing.T) {
|
||||||
r, ok, err := DetectLatest(repo)
|
r, ok, err := DetectLatest(tc.slug)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Fetch failed:", err)
|
t.Fatal("Fetch failed:", err)
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal(repo, "not found")
|
t.Fatal(tc.slug, "not found")
|
||||||
}
|
}
|
||||||
if r == nil {
|
if r == nil {
|
||||||
t.Fatal("Release not detected")
|
t.Fatal("Release not detected")
|
||||||
|
@ -72,14 +75,14 @@ func TestDetectReleasesForVariousArchives(t *testing.T) {
|
||||||
if !r.Version.Equals(semver.MustParse("1.2.3")) {
|
if !r.Version.Equals(semver.MustParse("1.2.3")) {
|
||||||
t.Error("")
|
t.Error("")
|
||||||
}
|
}
|
||||||
url := fmt.Sprintf("https://github.com/%s/releases/tag/v1.2.3", repo)
|
url := fmt.Sprintf("https://github.com/%s/releases/tag/%s1.2.3", tc.slug, tc.prefix)
|
||||||
if r.URL != url {
|
if r.URL != url {
|
||||||
t.Error("URL is not wrong. Want", url, "but got", r.URL)
|
t.Error("URL is not correct. Want", url, "but got", r.URL)
|
||||||
}
|
}
|
||||||
if r.ReleaseNotes == "" {
|
if r.ReleaseNotes == "" {
|
||||||
t.Error("Release note is unexpectedly empty")
|
t.Error("Release note is unexpectedly empty")
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(r.AssetURL, fmt.Sprintf("https://github.com/%s/releases/download/v1.2.3/", repo)) {
|
if !strings.HasPrefix(r.AssetURL, fmt.Sprintf("https://github.com/%s/releases/download/%s1.2.3/", tc.slug, tc.prefix)) {
|
||||||
t.Error("Unexpected asset URL:", r.AssetURL)
|
t.Error("Unexpected asset URL:", r.AssetURL)
|
||||||
}
|
}
|
||||||
if r.Name == "" {
|
if r.Name == "" {
|
||||||
|
|
Loading…
Reference in a new issue