From e1e2fefef44c5c18b60e3c8caa11172e36971e2a Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Fri, 26 Oct 2018 15:02:11 +0200 Subject: [PATCH] Adding unit tests for System --- system_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 system_test.go diff --git a/system_test.go b/system_test.go new file mode 100644 index 0000000..9920056 --- /dev/null +++ b/system_test.go @@ -0,0 +1,23 @@ +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 ...") + } +}