Files
MengMengCode 9fc3f1c5b8 feat: add Telegram API URL handling and version comparison utilities
- Implemented `telegramAPIURL` and `validateTelegramAPIURL` functions for constructing and validating Telegram API URLs.
- Added semantic versioning utilities in `version.go` to compare versions and validate semantic version formats.
- Created tests for version comparison logic in `version_test.go`.
- Introduced IMS call handling in `call_runtime.go`, including methods for dialing, answering, and hanging up calls.
- Added tests for incoming call handling and validation in `call_runtime_test.go`.
- Developed a new `PluginsCard` component for managing plugins via URL or file upload in the web interface.
- Implemented plugin management functions in `extensions.ts` and created an `ExtensionPage` for displaying plugin contributions.
2026-08-09 19:28:12 +08:00

35 lines
852 B
Go

package update
import "testing"
func TestIsNewerVersion(t *testing.T) {
tests := []struct {
current string
latest string
want bool
}{
{"0.0.3", "v0.0.4", true},
{"0.0.4", "v0.0.4", false},
{"0.1.0-dev", "v0.0.4", false},
{"0.1.0-dev", "v0.1.0", true},
{"1.2.3-rc.1", "v1.2.3-rc.2", true},
{"1.2.3", "v1.2.3-rc.2", false},
}
for _, item := range tests {
got, err := IsNewerVersion(item.current, item.latest)
if err != nil {
t.Errorf("IsNewerVersion(%q, %q): %v", item.current, item.latest, err)
continue
}
if got != item.want {
t.Errorf("IsNewerVersion(%q, %q) = %v, want %v", item.current, item.latest, got, item.want)
}
}
}
func TestIsNewerVersionRejectsInvalidRelease(t *testing.T) {
if _, err := IsNewerVersion("0.1.0", "nightly"); err == nil {
t.Fatal("invalid latest version was accepted")
}
}