1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:50:06 +00:00

fix(status): improve disk card display refs #551

This commit is contained in:
tw93
2026-03-08 23:46:46 +08:00
parent 24da1e2ac1
commit 8c53923ce8
4 changed files with 203 additions and 28 deletions

View File

@@ -0,0 +1,60 @@
package main
import (
"testing"
"github.com/shirou/gopsutil/v4/disk"
)
func TestShouldSkipDiskPartition(t *testing.T) {
tests := []struct {
name string
part disk.PartitionStat
want bool
}{
{
name: "keep local apfs root volume",
part: disk.PartitionStat{
Device: "/dev/disk3s1s1",
Mountpoint: "/",
Fstype: "apfs",
},
want: false,
},
{
name: "skip macfuse mirror mount",
part: disk.PartitionStat{
Device: "kaku-local:/",
Mountpoint: "/Users/tw93/Library/Caches/dev.kaku/sshfs/kaku-local",
Fstype: "macfuse",
},
want: true,
},
{
name: "skip smb share",
part: disk.PartitionStat{
Device: "//server/share",
Mountpoint: "/Volumes/share",
Fstype: "smbfs",
},
want: true,
},
{
name: "skip system volume",
part: disk.PartitionStat{
Device: "/dev/disk3s5",
Mountpoint: "/System/Volumes/Data",
Fstype: "apfs",
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := shouldSkipDiskPartition(tt.part); got != tt.want {
t.Fatalf("shouldSkipDiskPartition(%+v) = %v, want %v", tt.part, got, tt.want)
}
})
}
}