Refactor the code
Multiple code refactorings to make the code
simpler and increase the unit testing coverage.
* Golint findings are fixed.
* Xapp query function name changed from status to
config.
The functionality is slightly changed so that
- Vespa is started only after the xapp notification
subscription is successful and the vesmgr has received
the current xapp configuration from the xapp manager.
- The vesmgr goes to the main loop after that.
Change-Id: Ie2675c0543d4e4ce0a60b92a6c06a79b9e2cb2cd
Signed-off-by: Roni Riska <roni.riska@nokia.com>
diff --git a/cmd/vesmgr/subprocess_test.go b/cmd/vesmgr/subprocess_test.go
new file mode 100644
index 0000000..bf460d9
--- /dev/null
+++ b/cmd/vesmgr/subprocess_test.go
@@ -0,0 +1,31 @@
+package main
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestProcessRunning(t *testing.T) {
+ r := makeRunner("echo", "a")
+ ch := make(chan error)
+ r.run(ch)
+ err := <-ch
+ assert.Nil(t, err)
+}
+
+func TestProcessKill(t *testing.T) {
+ r := makeRunner("sleep", "20")
+ ch := make(chan error)
+ r.run(ch)
+ assert.Nil(t, r.kill())
+ <-ch // wait and seee that kills is actually done
+}
+
+func TestProcessRunningFails(t *testing.T) {
+ r := makeRunner("foobarbaz")
+ ch := make(chan error)
+ r.run(ch)
+ err := <-ch
+ assert.NotNil(t, err)
+}