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]:]
|
||||
}
|
||||
|
||||
release = &Release{AssetURL: url}
|
||||
release = &Release{
|
||||
AssetURL: url,
|
||||
DocumentURL: rel.GetHTMLURL(),
|
||||
Description: rel.GetBody(),
|
||||
}
|
||||
|
||||
release.Version, err = semver.Make(tag)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -27,10 +27,36 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
|
|||
t.Fatal("Release detected but nil returned for it")
|
||||
}
|
||||
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") {
|
||||
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'")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
|
||||
// Release represents a release asset for current OS and arch.
|
||||
type Release struct {
|
||||
Version semver.Version
|
||||
AssetURL string
|
||||
Version semver.Version
|
||||
AssetURL string
|
||||
DocumentURL string
|
||||
Description string
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue