2018-10-26 15:02:11 +02:00
|
|
|
package owrt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestService(t *testing.T) {
|
|
|
|
exec := createMockExecutor("", "", 0)
|
|
|
|
sys := NewSystemWithExecutor(exec)
|
|
|
|
res := sys.Service("network", "start")
|
|
|
|
if res.ReturnCode != 0 {
|
|
|
|
t.Error("Bad Return Code !")
|
|
|
|
}
|
|
|
|
if res.Stdout != "" {
|
|
|
|
fmt.Printf("[%s] - ", res.Stdout)
|
|
|
|
t.Error("Stdout is not empty ...")
|
|
|
|
}
|
|
|
|
if res.Stderr != "" {
|
|
|
|
fmt.Printf("[%s] - ", res.Stdout)
|
|
|
|
t.Error("Stderr is not empty ...")
|
|
|
|
}
|
|
|
|
}
|
2018-10-26 15:16:55 +02:00
|
|
|
|
|
|
|
func TestOpkg(t *testing.T) {
|
|
|
|
exec := createMockExecutor("", "", 0)
|
|
|
|
sys := NewSystemWithExecutor(exec)
|
|
|
|
res := sys.Opkg("update")
|
|
|
|
if res.ReturnCode != 0 {
|
|
|
|
t.Error("Bad Return Code !")
|
|
|
|
}
|
|
|
|
if res.Stdout != "" {
|
|
|
|
fmt.Printf("[%s] - ", res.Stdout)
|
|
|
|
t.Error("Stdout is not empty ...")
|
|
|
|
}
|
|
|
|
if res.Stderr != "" {
|
|
|
|
fmt.Printf("[%s] - ", res.Stdout)
|
|
|
|
t.Error("Stderr is not empty ...")
|
|
|
|
}
|
|
|
|
|
|
|
|
res = sys.Opkg("install", "ip")
|
|
|
|
if res.ReturnCode != 0 {
|
|
|
|
t.Error("Bad Return Code !")
|
|
|
|
}
|
|
|
|
if res.Stdout != "" {
|
|
|
|
fmt.Printf("[%s] - ", res.Stdout)
|
|
|
|
t.Error("Stdout is not empty ...")
|
|
|
|
}
|
|
|
|
if res.Stderr != "" {
|
|
|
|
fmt.Printf("[%s] - ", res.Stdout)
|
|
|
|
t.Error("Stderr is not empty ...")
|
|
|
|
}
|
|
|
|
}
|