fix(releaseupdate): a development build names no release to compare
This commit is contained in:
2 files changed
+8
-2
No files matched your search
@@ -193,9 +193,14 @@ func installable(r githubRelease) string {
|
||||
}
|
||||
|
||||
// ReleaseVersion is the release a build was cut from: a git-describe build
|
||||
// ("1.55.0-218-gabc123") is the same release as its tag.
|
||||
// ("1.55.0-218-gabc123") is the same release as its tag. A build that names no
|
||||
// release ("dev") has none, so nothing can be judged newer than it.
|
||||
func ReleaseVersion(version string) string {
|
||||
return buildSuffix.ReplaceAllString(version, "")
|
||||
version = buildSuffix.ReplaceAllString(version, "")
|
||||
if !semver.IsValid("v" + strings.TrimPrefix(version, "v")) {
|
||||
return ""
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
// installedAgent is the image the installer last switched to, recorded in a
|
||||
|
||||
@@ -18,6 +18,7 @@ func TestVersionStatusFor(t *testing.T) {
|
||||
{"running a different release", "1.55.0", "1.54.3", "1.55.0", true, statusDrift},
|
||||
{"older release installed", "1.54.3", "1.54.3", "1.55.0", true, statusUpdateAvailable},
|
||||
{"nothing running reported", "1.55.0", "", "1.55.0", false, statusUnknown},
|
||||
{"development build", releaseupdate.ReleaseVersion("dev+5eeb29955d2a"), "dev+5eeb29955d2a", "1.55.0", true, statusUnknown},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user