Files
3x-ui/web/service/panel_test.go
Farhad H. P. Shirvan f21ed92296 feat: add panel update functionality via web GUI (#4117)
* feat: add panel update functionality via web GUI

* feat: enhance panel update notifications in web GUI

* feat: implement panel update modal and enhance translation strings

* fix design
2026-04-28 18:46:55 +02:00

42 lines
1.1 KiB
Go

package service
import "testing"
func TestIsNewerVersion(t *testing.T) {
cases := []struct {
latest string
current string
want bool
}{
{"v2.9.4", "2.9.3", true},
{"v2.10.0", "2.9.9", true},
{"v2.9.3", "2.9.3", false},
{"v2.9.2", "2.9.3", false},
{"v3.0.0", "2.9.3", true},
}
for _, tc := range cases {
if got := isNewerVersion(tc.latest, tc.current); got != tc.want {
t.Fatalf("isNewerVersion(%q, %q) = %v, want %v", tc.latest, tc.current, got, tc.want)
}
}
}
func TestCompareVersionStringsRejectsUnexpectedFormats(t *testing.T) {
if _, ok := compareVersionStrings("latest", "2.9.3"); ok {
t.Fatal("expected non-semver latest tag to be rejected")
}
if _, ok := compareVersionStrings("v2.9", "2.9.3"); ok {
t.Fatal("expected short version to be rejected")
}
}
func TestShellQuote(t *testing.T) {
if got := shellQuote("/usr/bin/curl"); got != "'/usr/bin/curl'" {
t.Fatalf("unexpected quote result: %s", got)
}
if got := shellQuote("/tmp/a'b"); got != "'/tmp/a'\\''b'" {
t.Fatalf("unexpected quote result with single quote: %s", got)
}
}