node_exporter/collector/netstat_linux_test.go

30 lines
578 B
Go
Raw Normal View History

2014-11-24 23:30:07 +00:00
package collector
import (
"os"
"testing"
)
var fileName = "fixtures/netstat"
2014-11-24 23:30:07 +00:00
func TestNetStats(t *testing.T) {
file, err := os.Open(fileName)
2014-11-24 23:30:07 +00:00
if err != nil {
t.Fatal(err)
}
defer file.Close()
netStats, err := parseNetStats(file, fileName)
2014-11-24 23:30:07 +00:00
if err != nil {
t.Fatal(err)
}
if want, got := "102471", netStats["TcpExt"]["DelayedACKs"]; want != got {
t.Errorf("want netstat TCP DelayedACKs %s, got %s", want, got)
}
if want, got := "2786264347", netStats["IpExt"]["OutOctets"]; want != got {
t.Errorf("want netstat IP OutOctets %s, got %s", want, got)
}
}