github.com/anacrolix/torrent@v1.61.0/test_test.go (about) 1 package torrent 2 3 // Helpers for testing 4 5 import ( 6 "testing" 7 8 "github.com/go-quicktest/qt" 9 10 "github.com/anacrolix/torrent/metainfo" 11 ) 12 13 func newTestingClient(t testing.TB) *Client { 14 cl, err := NewClient(TestingConfig(t)) 15 qt.Assert(t, qt.IsNil(err)) 16 t.Cleanup(func() { 17 cl.Close() 18 }) 19 return cl 20 } 21 22 var testingTorrentInfoHash = metainfo.Hash{1} 23 24 // Basic opts for testing adding torrents I guess. 25 var testingAddTorrentOpts = AddTorrentOpts{ 26 InfoHash: testingTorrentInfoHash, 27 DisableInitialPieceCheck: true, 28 } 29 30 // Why would you call this? It doesn't add it to the Client... 31 func (cl *Client) newTorrentForTesting() *Torrent { 32 return cl.newTorrentOpt(testingAddTorrentOpts) 33 }