package event_sender

import (
	//"git.loafle.net/overflow/overflow_probe/agent_api/observer"
	//"git.loafle.net/overflow/overflow_probe/agent_api/observer/messages"
	"log"
	"strconv"
	"testing"
	"time"
)

func TestEventSender_Start(t *testing.T) {

	//observer.Notify("CONFIGMANAGER_LOADED", nil)

	c := make(chan bool, 1)
	err := Start(c)

	<-c

	if err != nil {
		log.Println("err: ", err)
	}
	time.Sleep(time.Second * 5)

	testNotify()

	time.Sleep(time.Second * 5)

}

func testNotify() {
	//time.Sleep(time.Second * 5)
	//es := GetInstance()

	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) + ")"

		cd := &Data{
			SensorId: "insanity",
			Data:     result,
		}
		AddEventData(cd)
		//observer.Notify(messages.QUEUE_EVENT, cd)
	}
	log.Println("New data Notify")
}
