From ad7a1b5de7e369658f1d1eed8145108f6fd5f089 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Fri, 25 Sep 2015 08:56:24 +0000 Subject: [PATCH] Test for BackgroundPublisher --- xfer/background_publisher_test.go | 26 ++++++++++++++++++++++++-- xfer/multi_publisher_test.go | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/xfer/background_publisher_test.go b/xfer/background_publisher_test.go index 60a1a6283d..21764adbe6 100644 --- a/xfer/background_publisher_test.go +++ b/xfer/background_publisher_test.go @@ -1,7 +1,29 @@ package xfer_test -import "testing" +import ( + "testing" + "bytes" + "time" + "runtime" + + "github.com/weaveworks/scope/xfer" + "github.com/weaveworks/scope/test" +) func TestBackgroundPublisher(t *testing.T) { - t.Skip("TODO") + mp := mockPublisher{} + backgroundPublisher := xfer.NewBackgroundPublisher(&mp) + defer backgroundPublisher.Stop() + runtime.Gosched() + + for i := 0; i < 10; i++ { + err := backgroundPublisher.Publish(&bytes.Buffer{}) + if err != nil { + t.Fatalf("%v", err) + } + + test.Poll(t, 100*time.Millisecond, i, func() interface{} { + return mp.count + }) + } } diff --git a/xfer/multi_publisher_test.go b/xfer/multi_publisher_test.go index 2664340b7d..943f4dca9a 100644 --- a/xfer/multi_publisher_test.go +++ b/xfer/multi_publisher_test.go @@ -33,6 +33,7 @@ func TestMultiPublisher(t *testing.T) { return "", nil, fmt.Errorf("invalid endpoint %s", endpoint) } }) + defer mp.Stop() mp.Set("a", []string{"a1", "a2"}) mp.Set("b", []string{"b2", "b3"})