wip: 重新整理 install cmd

This commit is contained in:
zhaoyupeng
2026-01-13 20:13:29 +08:00
parent fcbaa5be2f
commit 760784a5ac
15 changed files with 957 additions and 665 deletions

42
pkg/syscheck/disk_test.go Normal file
View File

@@ -0,0 +1,42 @@
package syscheck
import (
"context"
"testing"
)
func TestGetDiskSpace(t *testing.T) {
size, err := GetDiskSpace(context.Background())
if err != nil {
t.Fatalf("Failed to get disk space: %v", err)
}
if size <= 0 {
t.Errorf("expected disk space to be greater than 0, got %d", size)
}
t.Logf("Available disk space: %d bytes (%.2f GB)", size, float64(size)/(1024*1024*1024))
}
func TestGetDiskSpeed(t *testing.T) {
// Test with real disk I/O (warning: this writes 1GB to disk)
// Skip in short mode
if testing.Short() {
t.Skip("Skipping disk speed test in short mode")
}
rs, ws, err := GetDiskSpeed(context.Background())
if err != nil {
t.Fatalf("Failed to get disk speed: %v", err)
}
if rs <= 0 {
t.Errorf("expected read speed > 0, got %d", rs)
}
if ws <= 0 {
t.Errorf("expected write speed > 0, got %d", ws)
}
t.Logf("Read speed: %d bytes/s (%.2f MB/s)", rs, float64(rs)/(1024*1024))
t.Logf("Write speed: %d bytes/s (%.2f MB/s)", ws, float64(ws)/(1024*1024))
}