- Add shared resumable + SHA256SUMS-verified downloader (internal/fetch) and Windows executable swap/relaunch flow (internal/selfupdate, internal/app/appupdate_flow.go, --wait-pid in main.go/cli). - Add dedicated About page and sidebar update capsule with background release checks, download progress, and restart confirmation when VMs are running. - Implement plugin-contributed UI and backend/CLI locale packs (contributes.locales, LocalizedText extra tags, validation, runtime overlay, and PopupSelect language picker). - Move kernel-irqchip and Windows processor scheduling controls into VM Compute > Performance settings, hide Plugins settings gear for VM-only schemas, and align locked system plugin switches.
80 lines
2.7 KiB
Go
80 lines
2.7 KiB
Go
package version
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestCompare(t *testing.T) {
|
|
cases := []struct {
|
|
a, b string
|
|
want int
|
|
}{
|
|
{"v0.2.0", "v0.2.1", -1},
|
|
{"v0.2.1", "v0.2.1", 0},
|
|
{"v0.10.0", "v0.2.9", 1},
|
|
{"v1.0.0", "v0.9.9", 1},
|
|
{"dev", "v0.2.1", -1},
|
|
}
|
|
for _, tc := range cases {
|
|
if got := Compare(tc.a, tc.b); got != tc.want {
|
|
t.Errorf("Compare(%q, %q) = %d, want %d", tc.a, tc.b, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestCheckUpdateFindsNewerStableOnly(t *testing.T) {
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_, _ = w.Write([]byte(`[
|
|
{"tag_name":"runtime-3731afd","draft":false,"prerelease":false,"html_url":"https://example.test/rt","assets":[]},
|
|
{"tag_name":"v0.3.0-rc1","draft":false,"prerelease":true,"html_url":"https://example.test/rc","assets":[]},
|
|
{"tag_name":"v0.4.0","draft":true,"prerelease":false,"html_url":"https://example.test/draft","assets":[]},
|
|
{"tag_name":"v0.2.0","draft":false,"prerelease":false,"html_url":"https://example.test/v0.2.0","assets":[]},
|
|
{
|
|
"tag_name":"v0.2.2",
|
|
"draft":false,
|
|
"prerelease":false,
|
|
"published_at":"2026-11-29T00:00:00Z",
|
|
"html_url":"https://github.com/Nwflower/Reims-Go/releases/tag/v0.2.2",
|
|
"assets":[
|
|
{"name":"reims-go-cli-v0.2.2-windows-amd64.exe","size":11000000,"browser_download_url":"https://example.test/cli.exe"},
|
|
{"name":"reims-go-v0.2.2-windows-amd64.exe","size":14000000,"browser_download_url":"https://example.test/gui.exe"},
|
|
{"name":"reims-go-v0.2.2-windows-amd64.zip","size":6000000,"browser_download_url":"https://example.test/gui.zip"},
|
|
{"name":"SHA256SUMS.txt","size":200,"browser_download_url":"https://example.test/SHA256SUMS.txt"}
|
|
]
|
|
}
|
|
]`))
|
|
}))
|
|
defer srv.Close()
|
|
|
|
src := Source{APIBase: srv.URL, Repo: "Nwflower/Reims-Go", Client: srv.Client()}
|
|
info, err := src.CheckUpdate(context.Background(), "v0.2.1")
|
|
if err != nil {
|
|
t.Fatalf("CheckUpdate: %v", err)
|
|
}
|
|
if !info.HasUpdate {
|
|
t.Fatalf("expected HasUpdate=true, got %+v", info)
|
|
}
|
|
if info.Latest != "v0.2.2" {
|
|
t.Fatalf("Latest = %q, want v0.2.2", info.Latest)
|
|
}
|
|
if info.AssetName != "reims-go-v0.2.2-windows-amd64.exe" || info.DownloadURL != "https://example.test/gui.exe" {
|
|
t.Fatalf("unexpected asset: %+v", info)
|
|
}
|
|
if info.SumsURL != "https://example.test/SHA256SUMS.txt" {
|
|
t.Fatalf("SumsURL = %q, want the release's SHA256SUMS.txt", info.SumsURL)
|
|
}
|
|
|
|
// Same version reports up to date.
|
|
upToDate, err := src.CheckUpdate(context.Background(), "v0.2.2")
|
|
if err != nil {
|
|
t.Fatalf("CheckUpdate(same): %v", err)
|
|
}
|
|
if upToDate.HasUpdate {
|
|
t.Fatalf("expected HasUpdate=false when already on latest: %+v", upToDate)
|
|
}
|
|
}
|