mirror of
https://github.com/MedzikUser/go-github-selfupdate.git
synced 2024-08-15 03:25:29 +00:00
add document URL and description to Release struct
This commit is contained in:
parent
7cdec8424f
commit
b709a54c2d
3 changed files with 38 additions and 5 deletions
|
@ -112,7 +112,12 @@ func (d *ReleaseDetector) DetectLatest(slug string) (release *Release, found boo
|
||||||
tag = tag[indices[0]:]
|
tag = tag[indices[0]:]
|
||||||
}
|
}
|
||||||
|
|
||||||
release = &Release{AssetURL: url}
|
release = &Release{
|
||||||
|
AssetURL: url,
|
||||||
|
DocumentURL: rel.GetHTMLURL(),
|
||||||
|
Description: rel.GetBody(),
|
||||||
|
}
|
||||||
|
|
||||||
release.Version, err = semver.Make(tag)
|
release.Version, err = semver.Make(tag)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,36 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
|
||||||
t.Fatal("Release detected but nil returned for it")
|
t.Fatal("Release detected but nil returned for it")
|
||||||
}
|
}
|
||||||
if r.Version.LE(semver.MustParse("2.0.0")) {
|
if r.Version.LE(semver.MustParse("2.0.0")) {
|
||||||
t.Fatal("Incorrect version:", r.Version)
|
t.Error("Incorrect version:", r.Version)
|
||||||
}
|
}
|
||||||
if !strings.HasSuffix(r.AssetURL, ".zip") && !strings.HasSuffix(r.AssetURL, ".tar.gz") {
|
if !strings.HasSuffix(r.AssetURL, ".zip") && !strings.HasSuffix(r.AssetURL, ".tar.gz") {
|
||||||
t.Fatal("Incorrect URL for asset:", r.AssetURL)
|
t.Error("Incorrect URL for asset:", r.AssetURL)
|
||||||
|
}
|
||||||
|
if r.DocumentURL == "" {
|
||||||
|
t.Error("Document URL should not be empty")
|
||||||
|
}
|
||||||
|
if r.Description == "" {
|
||||||
|
t.Error("Description should not be empty for this repo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDetectReleaseButNoAsset(t *testing.T) {
|
||||||
|
_, ok, err := DetectLatest("rhysd/clever-f.vim")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Fetch failed:", err)
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
t.Fatal("When no asset found, result should be marked as 'not found'")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDetectNoRelease(t *testing.T) {
|
||||||
|
_, ok, err := DetectLatest("rhysd/clever-f.vim")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Fetch failed:", err)
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
t.Fatal("When no release found, result should be marked as 'not found'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,4 +8,6 @@ import (
|
||||||
type Release struct {
|
type Release struct {
|
||||||
Version semver.Version
|
Version semver.Version
|
||||||
AssetURL string
|
AssetURL string
|
||||||
|
DocumentURL string
|
||||||
|
Description string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue