From fffeb2ff417f7ba4343b6211358dab221d4fad53 Mon Sep 17 00:00:00 2001 From: geek Date: Fri, 28 Apr 2017 11:11:37 +0900 Subject: [PATCH] event test --- event_sender.go | 3 ++- event_sender_test.go | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/event_sender.go b/event_sender.go index 8a46a17..59a7929 100644 --- a/event_sender.go +++ b/event_sender.go @@ -40,6 +40,7 @@ func (es *EventSender) Start() { func (es *EventSender) Stop() { if es.sc != nil { close(es.sc) + es.sc = nil } } @@ -59,7 +60,7 @@ func (es *EventSender) checkQueue() { collectedData := tempCollectedData.Value.(*Data) collectedData.AgentId = agentIdentifier() result = append(result, collectedData) - log.Println("Result Len: ", len(result)) + //log.Println("Result Len: ", len(result)) } es.send(result) result = nil diff --git a/event_sender_test.go b/event_sender_test.go index 6183bc6..72fd92f 100644 --- a/event_sender_test.go +++ b/event_sender_test.go @@ -6,6 +6,7 @@ import ( "log" "testing" "time" + "strconv" ) func TestEventSender_Start(t *testing.T) { @@ -14,23 +15,25 @@ func TestEventSender_Start(t *testing.T) { es.Start() testNotify() - time.Sleep(time.Second * 100) + time.Sleep(time.Second * 1000) } func testNotify() { //time.Sleep(time.Second * 5) + for i := 0; i < 20; i ++{ result := make(map[string]string) - result["ab"] = "123" - result["cd"] = "456" - result["ef"] = "789" + result["ab"] = "123 ( " + strconv.Itoa(i) + ")" + result["cd"] = "456 ( "+ strconv.Itoa(i) + ")" + result["ef"] = "789 ( "+ strconv.Itoa(i) + ")" cd := &Data{ SensorId: "insanity", Data: result, } - log.Println("New data Notify") observer.Notify(messages.QUEUE_EVENT, cd) + } + log.Println("New data Notify") }