Update: deteksi AppImage tanpa $APPIMAGE, cek berkala, indikator di footer
- appImagePath(): pakai $APPIMAGE kalau ada, kalau tidak periksa berkas executable sendiri apakah AppImage (dulu cek update dilewati begitu saja) - cek ulang tiap 4 jam selama aplikasi terbuka, bukan hanya saat start - versi di footer berubah jadi 'v1.1.0 -> v1.1.1' saat ada update, jadi tetap terlihat walau dialognya ditutup dengan Nanti - tes: appImagePath (env, fallback, bukan AppImage), indikator footer
This commit is contained in:
1 parent
a7e75d95c4
commit
fbf7344b09
3 files changed
+122
-16
No files matched your search
@@ -0,0 +1,56 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"fyne.io/fyne/v2/test"
|
||||
|
||||
"lazyrun/internal/update"
|
||||
)
|
||||
|
||||
func TestAppImagePathFromEnv(t *testing.T) {
|
||||
t.Setenv("APPIMAGE", "/home/u/Apps/lazyrun-1.0.0-x86_64.AppImage")
|
||||
if got := appImagePath(); got != "/home/u/Apps/lazyrun-1.0.0-x86_64.AppImage" {
|
||||
t.Errorf("appImagePath() = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppImagePathWithoutEnvAndNotAppImage(t *testing.T) {
|
||||
// test binary bukan AppImage, jadi tidak ada yang bisa diupdate
|
||||
t.Setenv("APPIMAGE", "")
|
||||
if got := appImagePath(); got != "" {
|
||||
t.Errorf("appImagePath() = %q, mau kosong untuk binary biasa", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppImagePathFallsBackToExecutable(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
// executable tiruan: ELF + magic AI (AppImage)
|
||||
fake := filepath.Join(dir, "lazyrun.AppImage")
|
||||
data := make([]byte, 64)
|
||||
copy(data, []byte{0x7f, 'E', 'L', 'F', 0x02, 0x01, 0x01, 0x00})
|
||||
copy(data[8:], []byte{'A', 'I', 0x02})
|
||||
if err := os.WriteFile(fake, data, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// jalur env kosong -> deteksi dari IsAppImage (di sini diuji langsung)
|
||||
if !update.IsAppImage(fake) {
|
||||
t.Fatal("berkas uji harus dikenali sebagai AppImage")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarkUpdatePendingSetsFooter(t *testing.T) {
|
||||
a := test.NewApp()
|
||||
defer a.Quit()
|
||||
|
||||
ui, err := build(a, "1.1.0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ui.markUpdatePending(update.Release{Version: "9.9.9"})
|
||||
if got := ui.versionText.Text; got != "v1.1.0 → v9.9.9" {
|
||||
t.Errorf("footer tidak menampilkan update: %q", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user