event_sender_go/event_sender_test.go

42 lines
748 B
Go
Raw Normal View History

2017-04-27 09:58:50 +00:00
package event_sender
import (
"loafle.com/overflow/agent_api/observer"
"loafle.com/overflow/agent_api/observer/messages"
"log"
2017-04-28 02:12:20 +00:00
"strconv"
2017-04-27 09:58:50 +00:00
"testing"
"time"
)
func TestEventSender_Start(t *testing.T) {
2017-04-28 03:37:33 +00:00
observer.Notify("CONFIGMANAGER_LOADED", nil)
time.Sleep(time.Second * 5)
2017-04-27 09:58:50 +00:00
testNotify()
2017-04-28 03:37:33 +00:00
time.Sleep(time.Second * 100)
2017-04-27 09:58:50 +00:00
}
func testNotify() {
//time.Sleep(time.Second * 5)
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-04-27 09:58:50 +00:00
2017-04-28 02:12:20 +00:00
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
}