Test for BackgroundPublisher

This commit is contained in:
Tom Wilkie
2015-09-25 08:56:24 +00:00
parent b323388a92
commit 8265abad8b
2 changed files with 25 additions and 2 deletions

View File

@@ -1,7 +1,29 @@
package xfer_test
import "testing"
import (
"bytes"
"runtime"
"testing"
"time"
"github.com/weaveworks/scope/test"
"github.com/weaveworks/scope/xfer"
)
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
})
}
}

View File

@@ -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"})