commit b77a99b565104082c0f6c1872e8f47db15a3bf0f Author: Arlo Breault arlolra@gmail.com Date: Thu May 16 12:34:21 2019 -0400
Fix broker tests
NewBrokerContext now requires a logger so give it one to discard the logs. --- broker/snowflake-broker_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/broker/snowflake-broker_test.go b/broker/snowflake-broker_test.go index 463c5e7..0d50035 100644 --- a/broker/snowflake-broker_test.go +++ b/broker/snowflake-broker_test.go @@ -4,16 +4,25 @@ import ( "bytes" "container/heap" . "github.com/smartystreets/goconvey/convey" + "io/ioutil" + "log" "net" "net/http" "net/http/httptest" + "os" "testing" )
+func NullLogger() *log.Logger { + logger := log.New(os.Stdout, "", 0) + logger.SetOutput(ioutil.Discard) + return logger +} + func TestBroker(t *testing.T) {
Convey("Context", t, func() { - ctx := NewBrokerContext() + ctx := NewBrokerContext(NullLogger())
Convey("Adds Snowflake", func() { So(ctx.snowflakes.Len(), ShouldEqual, 0) @@ -175,7 +184,7 @@ func TestBroker(t *testing.T) { Convey("End-To-End", t, func() { done := make(chan bool) polled := make(chan bool) - ctx := NewBrokerContext() + ctx := NewBrokerContext(NullLogger())
// Proxy polls with its ID first... dataP := bytes.NewReader([]byte("test")) @@ -364,7 +373,7 @@ func TestGeoip(t *testing.T) { })
// Make sure things behave properly if geoip file fails to load - ctx := NewBrokerContext() + ctx := NewBrokerContext(NullLogger()) ctx.metrics.LoadGeoipDatabases("invalid_filename", "invalid_filename6") ctx.metrics.UpdateCountryStats("127.0.0.1") So(ctx.metrics.tablev4, ShouldEqual, nil)
tor-commits@lists.torproject.org