66 lines
1004 B
Go
66 lines
1004 B
Go
package data_sender_go
|
|
|
|
import (
|
|
"loafle.com/overflow/agent_api/observer"
|
|
"loafle.com/overflow/agent_api/observer/messages"
|
|
"strconv"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
type Result struct {
|
|
Data []byte
|
|
}
|
|
|
|
func TestTotal(t *testing.T) {
|
|
|
|
time.Sleep(time.Second * 5)
|
|
|
|
observer.Notify("CONFIGMANAGER_LOADED", nil)
|
|
|
|
time.Sleep(time.Second * 5)
|
|
|
|
for i := 0; i < 20; i++ {
|
|
testNotify(strconv.Itoa(i))
|
|
}
|
|
|
|
time.Sleep(time.Second * 12)
|
|
for i := 20; i < 30; i++ {
|
|
testNotify(strconv.Itoa(i))
|
|
}
|
|
|
|
time.Sleep(time.Second * 100)
|
|
}
|
|
|
|
func TestSend(t *testing.T) {
|
|
|
|
ds := &DataSender{}
|
|
ds.start()
|
|
|
|
for i := 0; i < 20; i++ {
|
|
testNotify(strconv.Itoa(i))
|
|
}
|
|
|
|
time.Sleep(time.Second * 12)
|
|
for i := 20; i < 30; i++ {
|
|
testNotify(strconv.Itoa(i))
|
|
}
|
|
|
|
time.Sleep(time.Second * 100)
|
|
}
|
|
|
|
func testNotify(val string) {
|
|
|
|
result := make(map[string]string)
|
|
result["a"] = val
|
|
result["b"] = val
|
|
result["c"] = val
|
|
|
|
cd := &Data{
|
|
SensorId: "insanity",
|
|
Data: result,
|
|
}
|
|
|
|
observer.Notify(messages.QUEUE_DATA, cd)
|
|
}
|