owrt/uci_wireless_conf_test.go

31 lines
830 B
Go

package owrt
import (
"io/ioutil"
"testing"
)
func TestUCIGetWirelessConf(t *testing.T) {
config, err := ioutil.ReadFile("./testdata/uci_show_wireless.txt")
if err != nil {
t.Fatal(err)
}
exec := createMockExecutor(string(config), "", 0)
uci := NewUCIWithExecutor(exec)
uci.LoadWirelessConf()
if g, e := uci.Wireless.DefaultInterface["Name"], "wifi-iface"; g != e {
t.Fatalf("DefaultDevice.Name is expected to be [%s] and we have [%s]", e, g)
}
config, err = ioutil.ReadFile("./testdata/uci_show_wireless_2_cards.txt")
if err != nil {
t.Fatal(err)
}
exec = createMockExecutor(string(config), "", 0)
uci = NewUCIWithExecutor(exec)
uci.LoadWirelessConf()
if g, e := uci.Wireless.Interfaces[1].Name, "wifi-iface"; g != e {
t.Fatalf("DefaultDevice.Name is expected to be [%s] and we have [%s]", e, g)
}
}