#! /bin/bash
-
+BASE_DIR=$( cd "$(dirname "$0")" ; pwd )
export GOPATH=$GOPATH:$BASE_DIR:$BASE_DIR/vendor
-
-go test -v -cover restapi/v1 -coverpkg=servicemgr,devicemgr,restapi -coverprofile cover.out
+ln -sf $BASE_DIR/vendor $BASE_DIR/vendor/src
+go test -v -cover restapi/v1 -coverpkg=servicemgr,devicemgr,restapi,discoverymgr -coverprofile cover.out
go tool cover -html=cover.out -o cover.html
firefox cover.html
\ No newline at end of file
--- /dev/null
+package test
+
+import (
+ dm "discoverymgr"
+ "testing"
+)
+
+var data = dm.AppReturnInfo{
+ AppName: "GreetWorldApp",
+ DeviceList: []dm.DeviceReturnInfo{
+ {
+ DeviceID: 1,
+ DeviceName: "hello world#1",
+ Status: "started",
+ DeviceIP: "10.113.175.144",
+ },
+ {
+ DeviceID: 2,
+ DeviceName: "hello world#2",
+ Status: "progressing",
+ DeviceIP: "10.113.175.144",
+ },
+ },
+}
+
+func TestDeviceList(t *testing.T) {
+ registerCh := make(chan error)
+ ServiceNames := []string{"Distributed Web Engine", "Television", "Soundbox"}
+ go RegisterDevice(ServiceNames, registerCh)
+ if err := <-registerCh; err != nil {
+ t.Error("fail")
+ }
+
+ ret, err := dm.DeviceList()
+ if err != nil {
+ t.Error("fail")
+ return
+ }
+ t.Log(ret)
+ if len(ret) != 1 {
+ t.Error("fail")
+ }
+
+ ExitChan <- 1
+
+ ret, err = dm.DeviceList()
+ if err != nil {
+ t.Error("fail")
+ return
+ }
+ t.Log(ret)
+ if len(ret) != 0 {
+ t.Error("fail")
+ }
+}
import (
"bytes"
"devicemgr"
+ "discoverymgr"
"encoding/json"
"io/ioutil"
"log"
ConstDeviceResourceUsageNetworkGet = "/api/v1/device/resource/usage/network"
// @TODO discovery mgr URI
+ ConstDiscoverymgrDevices = "/api/v1/discoverymgr/devices"
// Service mgr URI
ConstServicemgrServices = "/api/v1/servicemgr/services"
func init() {
devicemgr.InitDeviceMgr()
servicemgr.InitServiceMap()
+ discoverymgr.InitDiscovery()
router := NewRouter()
server = httptest.NewServer(router)
testGet(t, targetURI, http.StatusOK)
}
+func TestAPIV1DiscoverymgrDevicesGet(t *testing.T) {
+ targetURI := ConstDiscoverymgrDevices
+ testGet(t, targetURI, http.StatusOK)
+}
+
func TestAPIV1ServicemgrServicesPost(t *testing.T) {
registerService(t)
}