43 lines
1001 B
Go
43 lines
1001 B
Go
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))
|
|
}
|