github.com/smithx10/nomad@v0.9.1-rc1/client/fingerprint/network_windows_test.go (about) 1 package fingerprint 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/nomad/helper/testlog" 7 ) 8 9 func TestNetworkFingerPrint_linkspeed_parse(t *testing.T) { 10 f := &NetworkFingerprint{logger: testlog.HCLogger(t), interfaceDetector: &DefaultNetworkInterfaceDetector{}} 11 12 var outputTests = []struct { 13 in string 14 out int 15 }{ 16 {"10 Mbps", 10}, 17 {"2 bps", 0}, 18 {"1 Gbps", 1000}, 19 {"2Mbps", 0}, 20 {"1000 Kbps", 1}, 21 {"1 Kbps", 0}, 22 {"0 Mbps", 0}, 23 {"2 2 Mbps", 0}, 24 {"a Mbps", 0}, 25 {"1 Tbps", 0}, 26 } 27 28 for _, ot := range outputTests { 29 out := f.parseLinkSpeed(ot.in) 30 if out != ot.out { 31 t.Errorf("parseLinkSpeed(%s) => %d, should be %d", ot.in, out, ot.out) 32 } 33 } 34 }