Improving network_test.go ...
This way we don't need a real wifi card
This commit is contained in:
parent
1dbb62c490
commit
b34ccd3dee
|
@ -37,11 +37,15 @@ func (n *Network) ListInterfaces() []net.Interface {
|
|||
}
|
||||
|
||||
// ListWirelessInterfaces list all wifi cards
|
||||
func (n *Network) ListWirelessInterfaces() []net.Interface {
|
||||
// you need to provide the wireless file or "" to use
|
||||
// Linux default one "/proc/net/wireless"
|
||||
func (n *Network) ListWirelessInterfaces(wifiFile string) []net.Interface {
|
||||
var result []net.Interface
|
||||
var ifaceNames []string
|
||||
|
||||
wifiFile := "/proc/net/wireless"
|
||||
if wifiFile == "" {
|
||||
wifiFile = "/proc/net/wireless"
|
||||
}
|
||||
|
||||
wifiFileContent, err := ioutil.ReadFile(wifiFile)
|
||||
check(err)
|
||||
|
|
|
@ -15,7 +15,7 @@ func TestNetworkListInterfaces(t *testing.T) {
|
|||
|
||||
func TestListWirelessInterfaces(t *testing.T) {
|
||||
net := NewNetwork()
|
||||
res := net.ListWirelessInterfaces()
|
||||
res := net.ListWirelessInterfaces("./testdata/proc_net_wireless.txt")
|
||||
for _, el := range res {
|
||||
fmt.Printf("%s\n", el.Name)
|
||||
}
|
||||
|
|
Reference in New Issue