Cleanning test data

This commit is contained in:
Philippe Caseiro 2018-10-24 11:56:49 +02:00
parent e08dcc04d5
commit 2c218b00e1
2 changed files with 17 additions and 3 deletions

View File

@ -1,6 +1,9 @@
package owrt package owrt
import ( import (
"fmt"
"io/ioutil"
"os"
"testing" "testing"
) )
@ -29,12 +32,24 @@ func TestGetSysDevName(t *testing.T) {
iface.Encryption = ifaceEnc iface.Encryption = ifaceEnc
iface.Key = ifaceKey iface.Key = ifaceKey
if g, e := iface.GetSysDevName("testdata/sys/"), "wlan1"; g != e { testDirectory := "/tmp/sys/devices/platform/soc/soc:pcie/pci0000:00/0000:00:02.0/0000:02:00.0/net/wlan1/"
if err := os.MkdirAll(testDirectory, os.ModePerm); err != nil {
t.Fatalf("Impossible to setup test directory with test file")
}
testFile := fmt.Sprintf("%s/address", testDirectory)
d1 := []byte("00:00:00:84:00:63\n")
err := ioutil.WriteFile(testFile, d1, 0644)
if err != nil {
t.Fatalf("Impossible to setup test directory with test file")
}
if g, e := iface.GetSysDevName("/tmp/sys/"), "wlan1"; g != e {
t.Fatalf("UCIWirelessInterface.GetDeviceSysName() failed ! Got: %s Expect: %s", g, e) t.Fatalf("UCIWirelessInterface.GetDeviceSysName() failed ! Got: %s Expect: %s", g, e)
} }
iface.SysDevName = "wlanX" iface.SysDevName = "wlanX"
if g, e := iface.GetSysDevName("testdata/sys/"), "wlanX"; g != e { if g, e := iface.GetSysDevName("/tmp/sys/"), "wlanX"; g != e {
t.Fatalf("UCIWirelessInterface.GetDeviceSysName() failed ! Got: %s Expect: %s", g, e) t.Fatalf("UCIWirelessInterface.GetDeviceSysName() failed ! Got: %s Expect: %s", g, e)
} }
} }