open-nomad/client/fingerprint/network_windows_test.go
2018-06-13 15:40:56 -07:00

31 lines
618 B
Go

package fingerprint
import "testing"
func TestNetworkFingerPrint_linkspeed_parse(t *testing.T) {
f := &NetworkFingerprint{logger: testlog.Logger(t), interfaceDetector: &DefaultNetworkInterfaceDetector{}}
var outputTests = []struct {
in string
out int
}{
{"10 Mbps", 10},
{"2 bps", 0},
{"1 Gbps", 1000},
{"2Mbps", 0},
{"1000 Kbps", 1},
{"1 Kbps", 0},
{"0 Mbps", 0},
{"2 2 Mbps", 0},
{"a Mbps", 0},
{"1 Tbps", 0},
}
for _, ot := range outputTests {
out := f.parseLinkSpeed(ot.in)
if out != ot.out {
t.Errorf("parseLinkSpeed(%s) => %d, should be %d", ot.in, out, ot.out)
}
}
}