Skip to content

Commit

Permalink
Start moving to github.com/go-quicktest/qt
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Sep 30, 2024
1 parent 4af494e commit f59311e
Show file tree
Hide file tree
Showing 68 changed files with 628 additions and 588 deletions.
8 changes: 4 additions & 4 deletions bencode/both_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"os"
"testing"

qt "github.com/go-quicktest/qt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func loadFile(name string, t *testing.T) []byte {
data, err := os.ReadFile(name)
require.NoError(t, err)
qt.Assert(t, qt.IsNil(err))
return data
}

Expand All @@ -20,10 +20,10 @@ func testFileInterface(t *testing.T, filename string) {

var iface interface{}
err := Unmarshal(data1, &iface)
require.NoError(t, err)
qt.Assert(t, qt.IsNil(err))

data2, err := Marshal(iface)
require.NoError(t, err)
qt.Assert(t, qt.IsNil(err))

assert.EqualValues(t, data1, data2)
}
Expand Down
12 changes: 5 additions & 7 deletions bencode/bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package bencode
import (
"testing"

qt "github.com/frankban/quicktest"
qt "github.com/go-quicktest/qt"
)

func TestBytesMarshalNil(t *testing.T) {
Expand All @@ -18,8 +18,7 @@ type structWithBytes struct {

func TestMarshalNilStructBytes(t *testing.T) {
_, err := Marshal(structWithBytes{B: Bytes("i42e")})
c := qt.New(t)
c.Assert(err, qt.IsNotNil)
qt.Assert(t, qt.IsNotNil(err))
}

type structWithOmitEmptyBytes struct {
Expand All @@ -28,12 +27,11 @@ type structWithOmitEmptyBytes struct {
}

func TestMarshalNilStructBytesOmitEmpty(t *testing.T) {
c := qt.New(t)
b, err := Marshal(structWithOmitEmptyBytes{B: Bytes("i42e")})
c.Assert(err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))
t.Logf("%q", b)
var s structWithBytes
err = Unmarshal(b, &s)
c.Assert(err, qt.IsNil)
c.Check(s.B, qt.DeepEquals, Bytes("i42e"))
qt.Assert(t, qt.IsNil(err))
qt.Check(t, qt.DeepEquals(s.B, Bytes("i42e")))
}
46 changes: 23 additions & 23 deletions bencode/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
"strings"
"testing"

qt "github.com/frankban/quicktest"
"github.com/anacrolix/torrent/internal/qtnew"
qt "github.com/go-quicktest/qt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -68,10 +69,10 @@ func TestDecoderConsecutive(t *testing.T) {
d := NewDecoder(bytes.NewReader([]byte("i1ei2e")))
var i int
err := d.Decode(&i)
require.NoError(t, err)
qt.Assert(t, qt.IsNil(err))
require.EqualValues(t, 1, i)
err = d.Decode(&i)
require.NoError(t, err)
qt.Assert(t, qt.IsNil(err))
require.EqualValues(t, 2, i)
err = d.Decode(&i)
require.Equal(t, io.EOF, err)
Expand All @@ -86,19 +87,19 @@ func TestDecoderConsecutiveDicts(t *testing.T) {

var m map[string]interface{}

require.NoError(t, d.Decode(&m))
qt.Assert(t, qt.IsNil(d.Decode(&m)))
assert.Len(t, m, 1)
assert.Equal(t, "derp", m["herp"])
assert.Equal(t, "d3:wat1:ke17:oh baby a triple!", bb.String())
assert.EqualValues(t, 14, d.Offset)

require.NoError(t, d.Decode(&m))
qt.Assert(t, qt.IsNil(d.Decode(&m)))
assert.Equal(t, "k", m["wat"])
assert.Equal(t, "17:oh baby a triple!", bb.String())
assert.EqualValues(t, 24, d.Offset)

var s string
require.NoError(t, d.Decode(&s))
qt.Assert(t, qt.IsNil(d.Decode(&s)))
assert.Equal(t, "oh baby a triple!", s)
assert.EqualValues(t, 44, d.Offset)
}
Expand Down Expand Up @@ -150,7 +151,7 @@ func TestIgnoreUnmarshalTypeError(t *testing.T) {
}{}
require.Error(t, Unmarshal([]byte("d6:Normal5:helloe"), &s))
assert.NoError(t, Unmarshal([]byte("d6:Ignore5:helloe"), &s))
qt.Assert(t, Unmarshal([]byte("d6:Ignorei42ee"), &s), qt.IsNil)
qt.Assert(t, qt.IsNil(Unmarshal([]byte("d6:Ignorei42ee"), &s)))
assert.EqualValues(t, 42, s.Ignore)
}

Expand All @@ -162,8 +163,8 @@ func TestDecodeCustomSlice(t *testing.T) {
// We do a longer slice then a shorter slice to see if the buffers are
// shared.
d := NewDecoder(bytes.NewBufferString("3:\x01\x10\xff2:\x04\x0f"))
require.NoError(t, d.Decode(&fs3))
require.NoError(t, d.Decode(&fs2))
qt.Assert(t, qt.IsNil(d.Decode(&fs3)))
qt.Assert(t, qt.IsNil(d.Decode(&fs2)))
assert.EqualValues(t, []flag{1, 16, 255}, fs3)
assert.EqualValues(t, []flag{4, 15}, fs2)
}
Expand All @@ -183,19 +184,19 @@ func TestUnmarshalByteArray(t *testing.T) {
func TestDecodeDictIntoUnsupported(t *testing.T) {
// Any type that a dict shouldn't be unmarshallable into.
var i int
c := qt.New(t)
c := qtnew.New(t)
err := Unmarshal([]byte("d1:a1:be"), &i)
t.Log(err)
c.Check(err, qt.IsNotNil)
qt.Check(c, qt.IsNotNil(err))
}

func TestUnmarshalDictKeyNotString(t *testing.T) {
// Any type that a dict shouldn't be unmarshallable into.
var i int
c := qt.New(t)
c := qtnew.New(t)
err := Unmarshal([]byte("di42e3:yese"), &i)
t.Log(err)
c.Check(err, qt.Not(qt.IsNil))
qt.Check(c, qt.Not(qt.IsNil(err)))
}

type arbitraryReader struct{}
Expand All @@ -220,14 +221,13 @@ func decodeHugeString(t *testing.T, strLen int64, header, tail string, v interfa
// Ensure that bencode strings in various places obey the Decoder.MaxStrLen field.
func TestDecodeMaxStrLen(t *testing.T) {
t.Parallel()
c := qt.New(t)
test := func(header, tail string, v interface{}, maxStrLen MaxStrLen) {
strLen := maxStrLen
if strLen == 0 {
strLen = DefaultDecodeMaxStrLen
}
c.Assert(decodeHugeString(t, strLen, header, tail, v, maxStrLen), qt.IsNil)
c.Assert(decodeHugeString(t, strLen+1, header, tail, v, maxStrLen), qt.IsNotNil)
qt.Assert(t, qt.IsNil(decodeHugeString(t, strLen, header, tail, v, maxStrLen)))
qt.Assert(t, qt.IsNotNil(decodeHugeString(t, strLen+1, header, tail, v, maxStrLen)))
}
test("d%d:", "i0ee", new(interface{}), 0)
test("%d:", "", new(interface{}), DefaultDecodeMaxStrLen)
Expand All @@ -242,14 +242,14 @@ func TestDecodeStringIntoBoolPtr(t *testing.T) {
var m struct {
Private *bool `bencode:"private,omitempty"`
}
c := qt.New(t)
c := qtnew.New(t)
check := func(msg string, expectNil, expectTrue bool) {
m.Private = nil
c.Check(Unmarshal([]byte(msg), &m), qt.IsNil, qt.Commentf("%q", msg))
qt.Check(qt, qt.IsNil(Unmarshal([]byte(msg), &m), qt.Commentf("%q", msg))(c))

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

use of package qt not in selector

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

invalid operation: cannot call non-function qt.IsNil(Unmarshal([]byte(msg), &m), qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

too many arguments in call to qt.IsNil

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

use of package qt not in selector

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

invalid operation: cannot call non-function qt.IsNil(Unmarshal([]byte(msg), &m), qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

too many arguments in call to qt.IsNil

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

use of package qt not in selector

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

invalid operation: cannot call non-function qt.IsNil(Unmarshal([]byte(msg), &m), qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

too many arguments in call to qt.IsNil

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

use of package qt not in selector

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

invalid operation: cannot call non-function qt.IsNil(Unmarshal([]byte(msg), &m), qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

too many arguments in call to qt.IsNil

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

use of package qt not in selector

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

invalid operation: cannot call non-function qt.IsNil(Unmarshal([]byte(msg), &m), qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

too many arguments in call to qt.IsNil

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

use of package qt not in selector

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

invalid operation: cannot call non-function qt.IsNil(Unmarshal([]byte(msg), &m), qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 248 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

too many arguments in call to qt.IsNil
if expectNil {
c.Check(m.Private, qt.IsNil)
qt.Check(c, qt.IsNil(m.Private))
} else {
if c.Check(m.Private, qt.IsNotNil, qt.Commentf("%q", msg)) {
if qt.Check(qt, qt.IsNotNil(m.Private, qt.Commentf("%q", msg))(c)) {

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

use of package qt not in selector

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

invalid operation: cannot call non-function qt.IsNotNil(m.Private, qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

too many arguments in call to qt.IsNotNil

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

use of package qt not in selector

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

invalid operation: cannot call non-function qt.IsNotNil(m.Private, qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

too many arguments in call to qt.IsNotNil

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

use of package qt not in selector

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

invalid operation: cannot call non-function qt.IsNotNil(m.Private, qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

too many arguments in call to qt.IsNotNil

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

use of package qt not in selector

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

invalid operation: cannot call non-function qt.IsNotNil(m.Private, qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

too many arguments in call to qt.IsNotNil

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

use of package qt not in selector

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

invalid operation: cannot call non-function qt.IsNotNil(m.Private, qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

too many arguments in call to qt.IsNotNil

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

use of package qt not in selector

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

invalid operation: cannot call non-function qt.IsNotNil(m.Private, qt.Commentf("%q", msg)) (value of type qt.Checker)

Check failure on line 252 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

too many arguments in call to qt.IsNotNil
c.Check(*m.Private, qt.Equals, expectTrue, qt.Commentf("%q", msg))

Check failure on line 253 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

c.Check undefined (type *testing.T has no field or method Check)

Check failure on line 253 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

c.Check undefined (type *testing.T has no field or method Check)

Check failure on line 253 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

c.Check undefined (type *testing.T has no field or method Check)

Check failure on line 253 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

c.Check undefined (type *testing.T has no field or method Check)

Check failure on line 253 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

c.Check undefined (type *testing.T has no field or method Check)

Check failure on line 253 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

c.Check undefined (type *testing.T has no field or method Check)
}
}
Expand All @@ -270,7 +270,7 @@ func TestDecodeStringIntoBoolPtr(t *testing.T) {

// To set expectations about how our Decoder should work.
func TestJsonDecoderBehaviour(t *testing.T) {
c := qt.New(t)
c := qtnew.New(t)
test := func(input string, items int, finalErr error) {
d := json.NewDecoder(strings.NewReader(input))
actualItems := 0
Expand All @@ -283,8 +283,8 @@ func TestJsonDecoderBehaviour(t *testing.T) {
}
actualItems++
}
c.Check(firstErr, qt.Equals, finalErr)
c.Check(actualItems, qt.Equals, items)
qt.Check(qt, qt.Equals(firstErr, finalErr)(c))

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

use of package qt not in selector

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

invalid operation: cannot call non-function qt.Equals(firstErr, finalErr) (value of type qt.Checker)

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

use of package qt not in selector

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

invalid operation: cannot call non-function qt.Equals(firstErr, finalErr) (value of type qt.Checker)

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

use of package qt not in selector

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

invalid operation: cannot call non-function qt.Equals(firstErr, finalErr) (value of type qt.Checker)

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

use of package qt not in selector

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

invalid operation: cannot call non-function qt.Equals(firstErr, finalErr) (value of type qt.Checker)

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

use of package qt not in selector

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

invalid operation: cannot call non-function qt.Equals(firstErr, finalErr) (value of type qt.Checker)

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

use of package qt not in selector

Check failure on line 286 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

invalid operation: cannot call non-function qt.Equals(firstErr, finalErr) (value of type qt.Checker)
qt.Check(qt, qt.Equals(actualItems, items)(c))

Check failure on line 287 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-386 (1.22)

use of package qt not in selector

Check failure on line 287 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test-benchmarks (1.22)

use of package qt not in selector

Check failure on line 287 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / bench (1.22)

use of package qt not in selector

Check failure on line 287 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, ubuntu-latest)

use of package qt not in selector

Check failure on line 287 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, macos-latest)

use of package qt not in selector

Check failure on line 287 in bencode/decode_test.go

View workflow job for this annotation

GitHub Actions / test (1.22, windows-latest)

use of package qt not in selector
}
test("", 0, io.EOF)
test("{}", 1, io.EOF)
Expand Down
21 changes: 9 additions & 12 deletions bencode/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,28 @@ import (
"math/big"
"testing"

qt "github.com/frankban/quicktest"
"github.com/anacrolix/torrent/internal/qtnew"
qt "github.com/go-quicktest/qt"
"github.com/google/go-cmp/cmp"
)

var bencodeInterfaceChecker = qt.CmpEquals(cmp.Comparer(func(a, b *big.Int) bool {
return a.Cmp(b) == 0
}))

func Fuzz(f *testing.F) {
for _, ret := range random_encode_tests {
f.Add([]byte(ret.expected))
}
f.Fuzz(func(t *testing.T, b []byte) {
c := qt.New(t)
c := qtnew.New(t)
var d interface{}
err := Unmarshal(b, &d)
if err != nil {
t.Skip()
}
b0, err := Marshal(d)
c.Assert(err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))
var d0 interface{}
err = Unmarshal(b0, &d0)
c.Assert(err, qt.IsNil)
c.Assert(d0, bencodeInterfaceChecker, d)
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.CmpEquals(d0, d, cmp.Comparer(func(a, b *big.Int) bool { return a.Cmp(b) == 0 })))
})
}

Expand All @@ -40,14 +37,14 @@ func FuzzInterfaceRoundTrip(f *testing.F) {
f.Add([]byte(ret.expected))
}
f.Fuzz(func(t *testing.T, b []byte) {
c := qt.New(t)
c := qtnew.New(t)
var d interface{}
err := Unmarshal(b, &d)
if err != nil {
c.Skip(err)
}
b0, err := Marshal(d)
c.Assert(err, qt.IsNil)
c.Check(b0, qt.DeepEquals, b)
qt.Assert(t, qt.IsNil(err))
qt.Check(qt, qt.DeepEquals(b0, b)(c))
})
}
30 changes: 15 additions & 15 deletions client-nowasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ import (
"os"
"testing"

qt "github.com/frankban/quicktest"
"github.com/stretchr/testify/require"
qt "github.com/go-quicktest/qt"

"github.com/anacrolix/torrent/internal/qtnew"
"github.com/anacrolix/torrent/internal/testutil"
"github.com/anacrolix/torrent/storage"
)

func TestBoltPieceCompletionClosedWhenClientClosed(t *testing.T) {
c := qt.New(t)
c := qtnew.New(t)
cfg := TestingConfig(t)
pc, err := storage.NewBoltPieceCompletion(cfg.DataDir)
require.NoError(t, err)
qt.Assert(t, qt.IsNil(err))
ci := storage.NewFileWithCompletion(cfg.DataDir, pc)
defer ci.Close()
cfg.DefaultStorage = ci
cl, err := NewClient(cfg)
c.Assert(err, qt.IsNil, qt.Commentf("%#v", err))
qt.Assert(t, qt.IsNil(err, qt.Commentf("%#v", err)))
cl.Close()
// And again, https://github.com/anacrolix/torrent/issues/158
cl, err = NewClient(cfg)
require.NoError(t, err)
qt.Assert(t, qt.IsNil(err))
cl.Close()
}

Expand All @@ -51,22 +51,22 @@ func TestIssue335(t *testing.T) {
cfg.Debug = true
cfg.DataDir = dir
comp, err := storage.NewBoltPieceCompletion(dir)
c := qt.New(t)
c.Assert(err, qt.IsNil)
c := qtnew.New(t)
qt.Assert(t, qt.IsNil(err))
defer logErr(comp.Close, "closing bolt piece completion")
mmapStorage := storage.NewMMapWithCompletion(dir, comp)
defer logErr(mmapStorage.Close, "closing mmap storage")
cfg.DefaultStorage = mmapStorage
cl, err := NewClient(cfg)
c.Assert(err, qt.IsNil)
qt.Assert(t, qt.IsNil(err))
defer cl.Close()
tor, new, err := cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi))
c.Assert(err, qt.IsNil)
c.Assert(new, qt.IsTrue)
c.Assert(cl.WaitAll(), qt.IsTrue)
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.IsTrue(new))
qt.Assert(t, qt.IsTrue(cl.WaitAll()))
tor.Drop()
_, new, err = cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi))
c.Assert(err, qt.IsNil)
c.Assert(new, qt.IsTrue)
c.Assert(cl.WaitAll(), qt.IsTrue)
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.IsTrue(new))
qt.Assert(t, qt.IsTrue(cl.WaitAll()))
}
Loading

0 comments on commit f59311e

Please sign in to comment.