Fixing tests for new specs

This commit is contained in:
Philippe Caseiro 2018-10-17 15:54:48 +02:00 committed by William Petit
parent 94b4b220c6
commit dc195d0d21
3 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package openwrt
import (
"bufio"
"fmt"
"regexp"
"strings"
)
@ -76,5 +77,6 @@ func parseDhcpClientOut(out *CommandResult) *DhcpResult {
// AskForIP runs a dhclient ip request with udhcpc
func (dc *DhcpClient) AskForIP() *DhcpResult {
out := dc.exec.Run("udhcpc", "-i", dc.iface)
fmt.Printf("%s\n", out.Stdout)
return parseDhcpClientOut(out)
}

View File

@ -3,7 +3,7 @@ package openwrt
import "testing"
func TestDhcpClientAskForIP(t *testing.T) {
uexec := createMockExecutor("", "", 0)
uexec := createMockExecutor("udhcpc: ifconfig wlan1 192.168.42.20 netmask 255.255.255.0 broadcast +", "", 0)
dhc := NewDhcpClientWithExecutor("wlan1", uexec)
res := dhc.AskForIP()
if res.CmdRes.ReturnCode != 0 {

View File

@ -33,7 +33,7 @@ func TestGetWifiCells(t *testing.T) {
t.Errorf("The first Cell have a bad Encryption!\n %s is expected and we have %s", e, g)
}
if g, e := wifi.Cells[2].Encryption, "psk"; g != e {
if g, e := wifi.Cells[2].Encryption, "psk2"; g != e {
t.Errorf("The last Cell have a bad Encryption!\n %s is expected and we have %s", e, g)
}