65 lines
957 B
Go
65 lines
957 B
Go
|
package data_sender_go
|
||
|
|
||
|
import (
|
||
|
"git.loafle.net/overflow/agent_api/observer"
|
||
|
"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)
|
||
|
}
|