event_sender_go/event_sender_test.go

55 lines
907 B
Go
Raw Normal View History

2017-05-11 10:26:05 +00:00
package event_sender_go
2017-04-27 09:58:50 +00:00
import (
2017-05-29 11:20:46 +00:00
//"git.loafle.net/overflow/agent_api/observer"
//"git.loafle.net/overflow/agent_api/observer/messages"
2017-04-27 09:58:50 +00:00
"log"
2017-04-28 02:12:20 +00:00
"strconv"
2017-04-27 09:58:50 +00:00
"testing"
"time"
2017-05-23 02:17:31 +00:00
2017-04-27 09:58:50 +00:00
)
func TestEventSender_Start(t *testing.T) {
2017-05-16 06:29:43 +00:00
//observer.Notify("CONFIGMANAGER_LOADED", nil)
2017-04-28 03:37:33 +00:00
2017-05-16 06:52:20 +00:00
c := make(chan bool,1)
2017-05-16 06:29:43 +00:00
err := Start(c)
2017-05-16 06:52:20 +00:00
<- c
2017-05-16 06:29:43 +00:00
if err != nil {
log.Println("err: ", err)
}
2017-04-28 03:37:33 +00:00
time.Sleep(time.Second * 5)
2017-04-27 09:58:50 +00:00
testNotify()
2017-05-16 06:52:20 +00:00
time.Sleep(time.Second * 5)
2017-04-27 09:58:50 +00:00
}
func testNotify() {
//time.Sleep(time.Second * 5)
2017-05-16 06:29:43 +00:00
//es := GetInstance()
2017-04-27 09:58:50 +00:00
2017-04-28 02:12:20 +00:00
for i := 0; i < 20; i++ {
result := make(map[string]string)
result["ab"] = "123 ( " + strconv.Itoa(i) + ")"
result["cd"] = "456 ( " + strconv.Itoa(i) + ")"
result["ef"] = "789 ( " + strconv.Itoa(i) + ")"
2017-04-27 09:58:50 +00:00
2017-04-28 02:12:20 +00:00
cd := &Data{
SensorId: "insanity",
Data: result,
}
2017-05-16 06:29:43 +00:00
AddEventData(cd)
//observer.Notify(messages.QUEUE_EVENT, cd)
2017-04-28 02:11:37 +00:00
}
log.Println("New data Notify")
2017-04-27 09:58:50 +00:00
}
2017-05-23 02:17:31 +00:00