feat: 提交详情能看 diff,也能丢给 AI 审这一次改动。文件检查可单独排除路径,TODO 只认大写,避免把 todo 表和模块当成待办标记。
热力图按容器宽度铺满一年,不再横向滚动。托盘右键换成可换皮肤的弹层;更新下载显示进度,退出后再由脚本拉起安装器,避免还占着 exe。
This commit is contained in:
66
update_test.go
Normal file
66
update_test.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVersionNewer(t *testing.T) {
|
||||
if !versionNewer("2.0.1", "2.0.0") {
|
||||
t.Fatal("2.0.1 should be newer than 2.0.0")
|
||||
}
|
||||
if versionNewer("2.0.0", "2.0.0") {
|
||||
t.Fatal("same version is not newer")
|
||||
}
|
||||
if versionNewer("1.9.9", "2.0.0") {
|
||||
t.Fatal("1.9.9 should not be newer than 2.0.0")
|
||||
}
|
||||
if !versionNewer("v2.1.0", "2.0.9") {
|
||||
t.Fatal("v prefix should be ignored")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseSemver(t *testing.T) {
|
||||
got := parseSemver("v2.3.4-beta")
|
||||
if got != [3]int{2, 3, 4} {
|
||||
t.Fatalf("got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateLaunchScript(t *testing.T) {
|
||||
s := updateLaunchScript(4242, `C:\Temp\2.0.1-installer.exe`)
|
||||
for _, want := range []string{
|
||||
"set \"PID=4242\"",
|
||||
`start "" "C:\Temp\2.0.1-installer.exe"`,
|
||||
"tasklist /FI \"PID eq %PID%\"",
|
||||
":wait",
|
||||
":launch",
|
||||
} {
|
||||
if !strings.Contains(s, want) {
|
||||
t.Fatalf("script missing %q\n%s", want, s)
|
||||
}
|
||||
}
|
||||
if strings.Contains(s, " /S") {
|
||||
t.Fatal("installer must not be started silently; UAC/file lock would fail")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsWindowsPE(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pe := filepath.Join(dir, "ok.exe")
|
||||
html := filepath.Join(dir, "page.html")
|
||||
if err := os.WriteFile(pe, []byte("MZ\x90\x00fake"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(html, []byte("<!doctype html>"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !isWindowsPE(pe) {
|
||||
t.Fatal("MZ header should pass")
|
||||
}
|
||||
if isWindowsPE(html) {
|
||||
t.Fatal("html should not pass as installer")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user