Improving network_test.go ...

This way we don't need a real wifi card
This commit is contained in:
Philippe Caseiro 2018-09-21 14:36:06 +02:00
parent 1dbb62c490
commit b34ccd3dee
2 changed files with 7 additions and 3 deletions

View File

@ -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)

View File

@ -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)
}