- 新增 `updater` 模块实现 GitHub Release 版本异步检查与本地缓存 - 新增 `git air update` 与 `git air version` 命令支持一键升级及版本检查 - 优化 CLI 终端交互,在首页渲染时提供友好的新版本升级提示卡片
31 lines
630 B
Go
31 lines
630 B
Go
package updater
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestIsNewerVersion(t *testing.T) {
|
|
tests := []struct {
|
|
latest string
|
|
current string
|
|
expected bool
|
|
}{
|
|
{"v1.0.5", "v1.0.4", true},
|
|
{"v1.1.0", "v1.0.4", true},
|
|
{"v2.0.0", "v1.9.9", true},
|
|
{"v1.0.4", "v1.0.4", false},
|
|
{"v1.0.3", "v1.0.4", false},
|
|
{"v1.0.4.1", "v1.0.4", true},
|
|
{"1.0.5", "1.0.4", true},
|
|
{"", "v1.0.4", false},
|
|
{"v1.0.4", "", false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
got := IsNewerVersion(tt.latest, tt.current)
|
|
if got != tt.expected {
|
|
t.Errorf("IsNewerVersion(%q, %q) = %v, expected %v", tt.latest, tt.current, got, tt.expected)
|
|
}
|
|
}
|
|
}
|