2017-04-26 06:47:40 +00:00
|
|
|
package data_sender_go
|
|
|
|
|
|
|
|
import (
|
2017-04-26 09:07:44 +00:00
|
|
|
"fmt"
|
|
|
|
"loafle.com/overflow/agent_api/observer"
|
|
|
|
"loafle.com/overflow/queue_go"
|
2017-04-26 06:47:40 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2017-04-26 09:07:44 +00:00
|
|
|
type Result struct {
|
|
|
|
Data []byte
|
|
|
|
}
|
2017-04-26 06:47:40 +00:00
|
|
|
|
2017-04-26 09:07:44 +00:00
|
|
|
func TestSend(t *testing.T) {
|
2017-04-26 06:47:40 +00:00
|
|
|
|
2017-04-26 09:07:44 +00:00
|
|
|
ds := &DataSender{}
|
|
|
|
ds.Start()
|
|
|
|
testNotify()
|
2017-04-26 06:47:40 +00:00
|
|
|
|
2017-04-26 09:07:44 +00:00
|
|
|
time.Sleep(time.Second * 100)
|
2017-04-26 06:47:40 +00:00
|
|
|
}
|
|
|
|
|
2017-04-26 09:07:44 +00:00
|
|
|
func testNotify() {
|
|
|
|
time.Sleep(time.Second * 5)
|
|
|
|
|
|
|
|
result := make(map[string]string)
|
|
|
|
result["ab"] = "123"
|
|
|
|
result["cd"] = "456"
|
|
|
|
result["ef"] = "789"
|
|
|
|
|
|
|
|
cd := &Data{
|
|
|
|
SensorId: "insanity",
|
|
|
|
Data: result,
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("New data Notify")
|
|
|
|
observer.Notify(queue.StringType(queue.EVENT_TYPE), cd)
|
|
|
|
}
|