network_windows_test.go 824 B

1234567891011121314151617181920212223242526272829303132
  1. //go:build windows
  2. package network
  3. import (
  4. "net"
  5. "testing"
  6. )
  7. // nicExtraAll answers for every interface Go lists, with the state names the
  8. // network page uses on all platforms
  9. func TestNicExtraAllWindows(t *testing.T) {
  10. ifaces, err := net.Interfaces()
  11. if err != nil {
  12. t.Fatalf("net.Interfaces: %v", err)
  13. }
  14. extras := nicExtraAll(ifaces)
  15. valid := map[string]bool{"up": true, "down": true, "dormant": true, "testing": true, "unknown": true}
  16. for _, iface := range ifaces {
  17. extra, ok := extras[iface.Name]
  18. if !ok {
  19. t.Errorf("no details for interface %q", iface.Name)
  20. continue
  21. }
  22. if !valid[extra.OperState] {
  23. t.Errorf("%q OperState = %q", iface.Name, extra.OperState)
  24. }
  25. if extra.Speed == "" || extra.Duplex == "" {
  26. t.Errorf("%q has an empty speed or duplex: %+v", iface.Name, extra)
  27. }
  28. }
  29. }