simple configuremgr test EDGE-257
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Wed, 27 Mar 2019 07:32:57 +0000 (16:32 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Wed, 27 Mar 2019 07:32:57 +0000 (16:32 +0900)
src/configuremgr/configuremgr_test.go [new file with mode: 0644]

diff --git a/src/configuremgr/configuremgr_test.go b/src/configuremgr/configuremgr_test.go
new file mode 100644 (file)
index 0000000..5a38180
--- /dev/null
@@ -0,0 +1,48 @@
+package configuremgr_test
+
+import (
+  "testing"
+  "time"
+  "os/exec"
+  "fmt"
+
+  configuremgr     "configuremgr"
+  mockconfiguremgr "configuremgr/mock"
+)
+
+
+func TestBasicMockConfigureMgr(t *testing.T){
+
+  //copy event environment
+  watchDir := "/tmp/foo"
+  src := "./mock/mysum"
+  dst := watchDir
+
+
+  //linking interface
+  //mock function
+
+  //test object
+  configuremgrObj  := new(configuremgr.ConfigureMgr)
+  configuremgrObj.IDeviceDiscoveryMgr.PushConfPath  = mockconfiguremgr.PushConfPathDiscoveryDeviceMock
+  configuremgrObj.IAppExecuteMgr.PushConfPath = mockconfiguremgr.PushConfPathAppExecuteMock
+  configuremgrObj.IScoringMgr.PushLibPath     = mockconfiguremgr.PushLibPathScoringAppMock
+  configuremgrObj.Done                        = make(chan bool)
+
+  go configuremgrObj.Watch(watchDir)
+
+  //TODO : push /tmp/foo/simple directory using Cmd package
+  time.Sleep(time.Duration(1 * time.Second))
+  
+  command := fmt.Sprintf("cp -r %s %s", src, dst)
+  configuremgr.DLog.Println(command)
+
+  cmd := exec.Command("sh", "-c", command)
+  stdoutStderr, err := cmd.CombinedOutput()
+  configuremgr.DLog.Printf("%s", stdoutStderr)
+  if err != nil {
+    configuremgr.ELog.Fatal(err)
+  }
+
+  configuremgrObj.Done <- true
+}
\ No newline at end of file