sk-matrix-project/app/wails/pkg/system/system_test.go

55 lines
981 B
Go
Raw Normal View History

2023-07-09 23:04:17 +08:00
package system
import (
"fmt"
"path/filepath"
2023-07-12 00:35:32 +08:00
"skapp/backend/utils"
2023-07-09 23:04:17 +08:00
"testing"
)
func TestCpu(t *testing.T) {
fmt.Println(GetCpuInfo())
}
func TestMemory(t *testing.T) {
fmt.Println(GetVirtualMemory())
fmt.Println(GetSwapMemory())
}
func TestDisk(t *testing.T) {
partitions := GetDiskPartitions()
fmt.Println(partitions)
for _, partition := range partitions {
fmt.Println(GetDiskUsage(partition.Device))
}
fmt.Println(GetIOCounters())
}
func TestNetwork(t *testing.T) {
fmt.Println(GetNetWorkConnection())
}
func TestProcess(t *testing.T) {
processList := GetAllProcessPid()
for _, pid := range processList {
fmt.Println(GetProcessInfo(pid))
}
}
func TestScanDir(t *testing.T) {
fmt.Println(filepath.IsAbs("E:"), filepath.IsAbs("E:/"))
path, err := filepath.Abs("E:/")
if err != nil {
fmt.Println(err)
}
data, err := ScanDir(path)
if err != nil {
fmt.Println(err)
}
for _, entry := range data {
fmt.Printf("%+v\n", utils.Json(entry))
}
}