]> Sergey Matveev's repositories - btrtrc.git/blobdiff - client_test.go
Make fs a separate module
[btrtrc.git] / client_test.go
index c86243956ab5e8a9b93184c5561490c890b7a52f..95c0face918715bcb3c48ae5129b5a4bfa34aa88 100644 (file)
@@ -13,15 +13,14 @@ import (
        "testing/iotest"
        "time"
 
-       "github.com/frankban/quicktest"
-       "github.com/stretchr/testify/assert"
-       "github.com/stretchr/testify/require"
-
-       "github.com/anacrolix/log"
-
        "github.com/anacrolix/dht/v2"
+       "github.com/anacrolix/log"
        "github.com/anacrolix/missinggo/v2"
        "github.com/anacrolix/missinggo/v2/filecache"
+       "github.com/frankban/quicktest"
+       qt "github.com/frankban/quicktest"
+       "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/require"
 
        "github.com/anacrolix/torrent/bencode"
        "github.com/anacrolix/torrent/internal/testutil"
@@ -891,3 +890,16 @@ func TestBadPeerIpPort(t *testing.T) {
                })
        }
 }
+
+// https://github.com/anacrolix/torrent/issues/837
+func TestClientConfigSetHandlerNotIgnored(t *testing.T) {
+       cfg := NewDefaultClientConfig()
+       cfg.Logger.SetHandlers(log.DiscardHandler)
+       c := qt.New(t)
+       cl, err := NewClient(cfg)
+       c.Assert(err, qt.IsNil)
+       defer cl.Close()
+       c.Assert(cl.logger.Handlers, qt.HasLen, 1)
+       h := cl.logger.Handlers[0].(log.StreamHandler)
+       c.Check(h.W, qt.Equals, io.Discard)
+}