feat: 提交详情能看 diff,也能丢给 AI 审这一次改动。文件检查可单独排除路径,TODO 只认大写,避免把 todo 表和模块当成待办标记。
热力图按容器宽度铺满一年,不再横向滚动。托盘右键换成可换皮肤的弹层;更新下载显示进度,退出后再由脚本拉起安装器,避免还占着 exe。
This commit is contained in:
66
service/insights_test.go
Normal file
66
service/insights_test.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"view/model"
|
||||
)
|
||||
|
||||
func TestHasUpperTODO(t *testing.T) {
|
||||
cases := []struct {
|
||||
text string
|
||||
want bool
|
||||
}{
|
||||
{"// TODO: fix later", true},
|
||||
{"# TODO", true},
|
||||
{" TODO()", true},
|
||||
{"create table todo", false},
|
||||
{"type TodoService struct {}", false},
|
||||
{"const todos = []", false},
|
||||
{"TODOS := 1", false},
|
||||
{"myTODO", false},
|
||||
{"TODO_ITEM", false},
|
||||
{"// todo: later", false},
|
||||
{"// Todo: later", false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := hasUpperTODO(c.text); got != c.want {
|
||||
t.Errorf("hasUpperTODO(%q) = %v, want %v", c.text, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPathExcludedAndFilterStructure(t *testing.T) {
|
||||
rules := []model.ExclusionRule{{Pattern: "vendor"}, {Pattern: "src/todo"}, {Pattern: "*.pb.go"}}
|
||||
if !pathExcluded("vendor/lib.go", rules) {
|
||||
t.Fatal("vendor dir should be excluded")
|
||||
}
|
||||
if !pathExcluded("src/todo/list.go", rules) {
|
||||
t.Fatal("src/todo dir should be excluded")
|
||||
}
|
||||
if !pathExcluded("api/user.pb.go", rules) {
|
||||
t.Fatal("*.pb.go should be excluded")
|
||||
}
|
||||
if pathExcluded("src/app/main.go", rules) {
|
||||
t.Fatal("normal source should stay")
|
||||
}
|
||||
|
||||
s := model.StructureStats{
|
||||
Files: []model.FileEntry{
|
||||
{Path: "src/app/main.go"},
|
||||
{Path: "vendor/lib.go"},
|
||||
{Path: "src/todo/list.go"},
|
||||
},
|
||||
LargeFiles: []model.FileEntry{{Path: "vendor/huge.bin"}},
|
||||
Folders: []model.FolderStat{{Name: "vendor"}, {Name: "src"}},
|
||||
}
|
||||
got := filterStructureForInsights(s, rules)
|
||||
if len(got.Files) != 1 || got.Files[0].Path != "src/app/main.go" {
|
||||
t.Fatalf("files=%#v", got.Files)
|
||||
}
|
||||
if len(got.LargeFiles) != 0 {
|
||||
t.Fatalf("large=%#v", got.LargeFiles)
|
||||
}
|
||||
if len(got.Folders) != 1 || got.Folders[0].Name != "src" {
|
||||
t.Fatalf("folders=%#v", got.Folders)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user