open-nomad/client/fingerprint/network_windows_test.go

31 lines
618 B
Go
Raw Normal View History

package fingerprint
import "testing"
func TestNetworkFingerPrint_linkspeed_parse(t *testing.T) {
2018-06-13 22:33:25 +00:00
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)
}
}
}