[ Cmii ] [ Octopus ] - reformat agent-go - 1
This commit is contained in:
44
agent-go/a_status/Network_test.go
Normal file
44
agent-go/a_status/Network_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package a_status
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
"wdd.io/agent-common/utils"
|
||||
)
|
||||
|
||||
func TestMatchNetInterfaceRight(t *testing.T) {
|
||||
interfaceNames := []string{"eth0", "eth1", "enp3s0", "wlan0", "lo", "ens12", "eno1", "asdas", "en0"}
|
||||
|
||||
for _, name := range interfaceNames {
|
||||
if MatchNetInterfaceRight(name) {
|
||||
t.Logf("匹配到的网卡名称: %s\n", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetNetworkMetric(t *testing.T) {
|
||||
metric, err := GetNetworkMetric()
|
||||
if err != nil {
|
||||
t.Logf("get network metric error %s\n", err.Error())
|
||||
}
|
||||
|
||||
for _, networkMetric := range metric {
|
||||
fmt.Println()
|
||||
bytes, _ := json.MarshalIndent(networkMetric, "", " ")
|
||||
fmt.Println(string(bytes))
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetNetworkInfo(t *testing.T) {
|
||||
networkInfos, err := GetNetworkInfo()
|
||||
if err != nil {
|
||||
t.Errorf("GetNetworkInfo error of %s", err)
|
||||
}
|
||||
|
||||
for _, networkInfo := range networkInfos {
|
||||
utils.BeautifulPrint(networkInfo)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user