Fixing unit tests for UCIDHCPConf

This commit is contained in:
Philippe Caseiro 2018-10-26 11:39:47 +02:00
parent 6f2598aff2
commit e5ebf1ce11
2 changed files with 14 additions and 7 deletions

View File

@ -36,7 +36,6 @@ func (dh *UCIDHCPConf) Create() *Action {
return result return result
} }
for key, value := range conf { for key, value := range conf {
fmt.Printf("DEBUG %s == %s\n", key, value)
if value == "" { if value == "" {
return &Action{ return &Action{
CommandResult: &CommandResult{ CommandResult: &CommandResult{

View File

@ -12,6 +12,7 @@ const (
ifNetmaskDHCP = "255.255.255.0" ifNetmaskDHCP = "255.255.255.0"
ifDNSDHCP = "192.168.59.1" ifDNSDHCP = "192.168.59.1"
ifIFTypeDHCP = "bridge" ifIFTypeDHCP = "bridge"
ifLeaseTimeDHCP = "4h"
ifMetricDHCP = "9000" ifMetricDHCP = "9000"
ifRangeLimitDHCP = "10" ifRangeLimitDHCP = "10"
ifStartIPDHCP = "192.168.59.10" ifStartIPDHCP = "192.168.59.10"
@ -31,7 +32,8 @@ func TestNetCreateWithDHCP(t *testing.T) {
iface.IFType = ifIFTypeDHCP iface.IFType = ifIFTypeDHCP
iface.Metric = ifMetricDHCP iface.Metric = ifMetricDHCP
iface.DHCP.Name = ifNameDHCP iface.DHCP.Name = ifNameDHCP
iface.DHCP.LeaseTime = ifNameDHCP iface.DHCP.IFName = ifIFNameDHCP
iface.DHCP.LeaseTime = ifLeaseTimeDHCP
iface.DHCP.RangeLimit = ifRangeLimitDHCP iface.DHCP.RangeLimit = ifRangeLimitDHCP
iface.DHCP.StartIP = ifStartIPDHCP iface.DHCP.StartIP = ifStartIPDHCP
@ -54,19 +56,25 @@ func TestNetUpdateWithDHCP(t *testing.T) {
iface.IFType = ifIFTypeDHCP iface.IFType = ifIFTypeDHCP
iface.Metric = ifMetricDHCP iface.Metric = ifMetricDHCP
iface.DHCP.Name = ifNameDHCP iface.DHCP.Name = ifNameDHCP
iface.DHCP.LeaseTime = ifNameDHCP iface.DHCP.IFName = ifIFName
iface.DHCP.LeaseTime = ifLeaseTimeDHCP
iface.DHCP.RangeLimit = ifRangeLimitDHCP iface.DHCP.RangeLimit = ifRangeLimitDHCP
iface.DHCP.StartIP = ifStartIPDHCP iface.DHCP.StartIP = ifStartIPDHCP
if iface.Create().ReturnCode != 0 { cr := iface.Create()
t.Fatalf("UCINetworkInterface.Create() failed !") if cr.ReturnCode != 0 {
t.Fatalf("UCIDHCPConf.Create() failed !\n\tStdout: %s\n\tStderr: %s\n\tReturnCode: %d\n\tCommand: %s\n",
cr.Stdout,
cr.Stderr,
cr.ReturnCode,
cr.Command)
} }
iface.Metric = "1000" iface.Metric = "1000"
iface.DHCP.RangeLimit = "100" iface.DHCP.RangeLimit = "100"
if iface.Update().ReturnCode != 0 { if iface.Update().ReturnCode != 0 {
t.Fatalf("UCINetworkInterface.Update() failed !") t.Fatalf("UCIDHCPConf.Update() failed !")
} }
} }
@ -84,7 +92,7 @@ func TestNetDeleteWithDHCP(t *testing.T) {
iface.IFType = ifIFTypeDHCP iface.IFType = ifIFTypeDHCP
iface.Metric = ifMetricDHCP iface.Metric = ifMetricDHCP
iface.DHCP.Name = ifNameDHCP iface.DHCP.Name = ifNameDHCP
iface.DHCP.LeaseTime = ifNameDHCP iface.DHCP.LeaseTime = ifLeaseTimeDHCP
iface.DHCP.RangeLimit = ifRangeLimitDHCP iface.DHCP.RangeLimit = ifRangeLimitDHCP
iface.DHCP.StartIP = ifStartIPDHCP iface.DHCP.StartIP = ifStartIPDHCP