From dc195d0d21c8312953a7458cd46994c9488eecd6 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Wed, 17 Oct 2018 15:54:48 +0200 Subject: [PATCH] Fixing tests for new specs --- openwrt/dhcp_client.go | 2 ++ openwrt/dhcp_client_test.go | 2 +- openwrt/wifi_scanner_test.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openwrt/dhcp_client.go b/openwrt/dhcp_client.go index b4bd2e7..9a14e3b 100644 --- a/openwrt/dhcp_client.go +++ b/openwrt/dhcp_client.go @@ -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) } diff --git a/openwrt/dhcp_client_test.go b/openwrt/dhcp_client_test.go index 87959aa..3b8fb63 100644 --- a/openwrt/dhcp_client_test.go +++ b/openwrt/dhcp_client_test.go @@ -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 { diff --git a/openwrt/wifi_scanner_test.go b/openwrt/wifi_scanner_test.go index 3c93af2..57b96e8 100644 --- a/openwrt/wifi_scanner_test.go +++ b/openwrt/wifi_scanner_test.go @@ -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) }