package owrt import ( "testing" ) const ( ifNameDHCP = "cadoles" ifProtoDHCP = "static" ifIFNameDHCP = "cdl-fake" ifIPAddrDHCP = "192.168.59.1" ifNetmaskDHCP = "255.255.255.0" ifDNSDHCP = "192.168.59.1" ifIFTypeDHCP = "bridge" ifMetricDHCP = "9000" ifRangeLimitDHCP = "10" ifStartIPDHCP = "192.168.59.10" ) func TestNetCreateWithDHCP(t *testing.T) { exec := createMockExecutor("", "", 0) uci := NewUCIWithExecutor(exec) iface := NewUCINetworkInterface(uci) iface.Name = ifNameDHCP iface.Proto = ifProtoDHCP iface.IFName = ifIFNameDHCP iface.IPAddr = ifIPAddrDHCP iface.Netmask = ifNetmaskDHCP iface.DNS = ifDNSDHCP iface.IFType = ifIFTypeDHCP iface.Metric = ifMetricDHCP iface.DHCP.Name = ifNameDHCP iface.DHCP.LeaseTime = ifNameDHCP iface.DHCP.RangeLimit = ifRangeLimitDHCP iface.DHCP.StartIP = ifStartIPDHCP if iface.Create().ReturnCode != 0 { t.Fatalf("UCINetworkInterface.Create() failed !") } } func TestNetUpdateWithDHCP(t *testing.T) { exec := createMockExecutor("", "", 0) uci := NewUCIWithExecutor(exec) iface := NewUCINetworkInterface(uci) iface.Name = ifNameDHCP iface.Proto = ifProtoDHCP iface.IFName = ifIFNameDHCP iface.IPAddr = ifIPAddrDHCP iface.Netmask = ifNetmaskDHCP iface.DNS = ifDNSDHCP iface.IFType = ifIFTypeDHCP iface.Metric = ifMetricDHCP iface.DHCP.Name = ifNameDHCP iface.DHCP.LeaseTime = ifNameDHCP iface.DHCP.RangeLimit = ifRangeLimitDHCP iface.DHCP.StartIP = ifStartIPDHCP if iface.Create().ReturnCode != 0 { t.Fatalf("UCINetworkInterface.Create() failed !") } iface.Metric = "1000" iface.DHCP.RangeLimit = "100" if iface.Update().ReturnCode != 0 { t.Fatalf("UCINetworkInterface.Update() failed !") } } func TestNetDeleteWithDHCP(t *testing.T) { exec := createMockExecutor("", "", 0) uci := NewUCIWithExecutor(exec) iface := NewUCINetworkInterface(uci) iface.Name = ifNameDHCP iface.Proto = ifProtoDHCP iface.IFName = ifIFNameDHCP iface.IPAddr = ifIPAddrDHCP iface.Netmask = ifNetmaskDHCP iface.DNS = ifDNSDHCP iface.IFType = ifIFTypeDHCP iface.Metric = ifMetricDHCP iface.DHCP.Name = ifNameDHCP iface.DHCP.LeaseTime = ifNameDHCP iface.DHCP.RangeLimit = ifRangeLimitDHCP iface.DHCP.StartIP = ifStartIPDHCP if iface.Delete().ReturnCode != 0 { t.Fatalf("UCINetworkInterface.Delete() failed !") } }