github.com/frankban/quicktest v1.14.6
github.com/fsnotify/fsnotify v1.5.4
github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916
+ github.com/go-quicktest/qt v1.101.0
github.com/google/btree v1.1.2
github.com/google/go-cmp v0.6.0
github.com/gorilla/websocket v1.5.0
github.com/prometheus/common v0.35.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
- github.com/rogpeppe/go-internal v1.9.0 // indirect
+ github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417 // indirect
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 // indirect
github.com/sethvargo/go-envconfig v0.8.2 // indirect
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
+github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
+github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
-github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
+github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
+github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417 h1:Lt9DzQALzHoDwMBGJ6v8ObDPR0dzr2a6sXTB1Fq7IHs=
github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA=
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 h1:GHRpF1pTW19a8tTFrMLUcfWwyC0pnifVo2ClaLq+hP8=
import (
"testing"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
+ "github.com/go-quicktest/qt"
"github.com/anacrolix/torrent/metainfo"
)
td := t.TempDir()
pc, err := NewBoltPieceCompletion(td)
- require.NoError(t, err)
+ qt.Assert(t, qt.IsNil(err))
defer pc.Close()
pk := metainfo.PieceKey{}
b, err := pc.Get(pk)
- require.NoError(t, err)
- assert.False(t, b.Ok)
+ qt.Assert(t, qt.IsNil(err))
+ qt.Check(t, qt.IsFalse(b.Ok))
- require.NoError(t, pc.Set(pk, false))
+ qt.Check(t, qt.IsNil(pc.Set(pk, false)))
b, err = pc.Get(pk)
- require.NoError(t, err)
- assert.Equal(t, Completion{Complete: false, Ok: true}, b)
+ qt.Assert(t, qt.IsNil(err))
+ qt.Check(t, qt.Equals(b, Completion{Complete: false, Ok: true}))
- require.NoError(t, pc.Set(pk, true))
+ qt.Check(t, qt.IsNil(pc.Set(pk, true)))
b, err = pc.Get(pk)
- require.NoError(t, err)
- assert.Equal(t, Completion{Complete: true, Ok: true}, b)
+ qt.Assert(t, qt.IsNil(err))
+ qt.Check(t, qt.Equals(b, Completion{Complete: true, Ok: true}))
}
import (
"testing"
- qt "github.com/frankban/quicktest"
- "github.com/stretchr/testify/assert"
+ "github.com/go-quicktest/qt"
"github.com/anacrolix/torrent/common"
"github.com/anacrolix/torrent/metainfo"
},
},
}
- c := qt.New(t)
check := func(off, n int64, expected ...requiredLength) {
- c.Check(extentCompleteRequiredLengths(info, off, n), qt.DeepEquals, expected)
+ qt.Check(t, qt.DeepEquals(extentCompleteRequiredLengths(info, off, n), expected))
}
check(0, 0)
check(0, 1, requiredLength{FileIndex: 0, Length: 1})
{Path: []string{"b"}, Length: 3},
},
}
- c := qt.New(t)
check := func(off, n int64, expected ...requiredLength) {
- c.Check(extentCompleteRequiredLengths(info, off, n), qt.DeepEquals, expected)
+ qt.Assert(t, qt.DeepEquals(extentCompleteRequiredLengths(info, off, n), expected))
}
- assert.Empty(t, extentCompleteRequiredLengths(info, 0, 0))
- assert.EqualValues(t, []requiredLength{
+ qt.Check(t, qt.HasLen(extentCompleteRequiredLengths(info, 0, 0), 0))
+ qt.Check(t, qt.DeepEquals(extentCompleteRequiredLengths(info, 0, 1), []requiredLength{
{FileIndex: 0, Length: 1},
- }, extentCompleteRequiredLengths(info, 0, 1))
- assert.EqualValues(t, []requiredLength{
+ }))
+ qt.Check(t, qt.DeepEquals(extentCompleteRequiredLengths(info, 0, 2), []requiredLength{
{FileIndex: 0, Length: 2},
- }, extentCompleteRequiredLengths(info, 0, 2))
- assert.EqualValues(t, []requiredLength{
+ }))
+ qt.Check(t, qt.DeepEquals(extentCompleteRequiredLengths(info, 0, 3), []requiredLength{
{FileIndex: 0, Length: 2},
{FileIndex: 1, Length: 1},
- }, extentCompleteRequiredLengths(info, 0, 3))
- assert.EqualValues(t, []requiredLength{
+ }))
+ qt.Check(t, qt.DeepEquals(extentCompleteRequiredLengths(info, 2, 2), []requiredLength{
{FileIndex: 1, Length: 2},
- }, extentCompleteRequiredLengths(info, 2, 2))
- assert.EqualValues(t, []requiredLength{
+ }))
+ qt.Check(t, qt.DeepEquals(extentCompleteRequiredLengths(info, 4, 1), []requiredLength{
{FileIndex: 1, Length: 3},
- }, extentCompleteRequiredLengths(info, 4, 1))
- assert.Len(t, extentCompleteRequiredLengths(info, 5, 0), 0)
+ }))
+ qt.Check(t, qt.HasLen(extentCompleteRequiredLengths(info, 5, 0), 0))
check(6, 1)
}
"testing"
"github.com/anacrolix/missinggo/v2"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
+ "github.com/go-quicktest/qt"
"github.com/anacrolix/torrent/metainfo"
)
Pieces: make([]byte, 20),
}
ts, err := s.OpenTorrent(context.Background(), info, metainfo.Hash{})
- assert.NoError(t, err)
+ qt.Assert(t, qt.IsNil(err))
f, err := os.Create(filepath.Join(td, "a"))
- require.NoError(t, err)
+ qt.Assert(t, qt.IsNil(err))
err = f.Truncate(1)
- require.NoError(t, err)
+ qt.Assert(t, qt.IsNil(err))
f.Close()
var buf bytes.Buffer
p := info.Piece(0)
n, err := io.Copy(&buf, io.NewSectionReader(ts.Piece(p), 0, p.Length()))
- assert.EqualValues(t, 1, n)
+ qt.Check(t, qt.Equals(n, int64(1)))
switch err {
case nil, io.EOF:
default:
- t.Errorf("expected nil or EOF error from truncated piece, got %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
}
"testing"
"github.com/anacrolix/missinggo/v2/resource"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
+ "github.com/go-quicktest/qt"
"github.com/anacrolix/torrent/metainfo"
)
}
c := NewClient(ci)
t1, err := c.OpenTorrent(context.Background(), &info, metainfo.HashBytes([]byte("a")))
- require.NoError(t, err)
+ qt.Assert(t, qt.IsNil(err))
defer t1.Close()
t2, err := c.OpenTorrent(context.Background(), &info, metainfo.HashBytes([]byte("b")))
- require.NoError(t, err)
+ qt.Assert(t, qt.IsNil(err))
defer t2.Close()
t2p := t2.Piece(info.Piece(0))
- assert.NoError(t, t1.Close())
- assert.NotPanics(t, func() { t2p.Completion() })
+ qt.Check(t, qt.IsNil(t1.Close()))
+ t2p.Completion()
}
func TestIssue95File(t *testing.T) {
"testing"
g "github.com/anacrolix/generics"
- "github.com/stretchr/testify/require"
+ "github.com/go-quicktest/qt"
"github.com/anacrolix/torrent/metainfo"
)
Pieces: make([]byte, 20),
}
ts, err := cs.OpenTorrent(context.Background(), info, metainfo.Hash{})
- require.NoError(t, err)
+ qt.Assert(t, qt.IsNil(err))
p := ts.PieceWithHash(info.Piece(0), g.None[[]byte]())
- require.NoError(t, p.MarkComplete())
- // require.False(t, p.GetIsComplete())
+ qt.Check(t, qt.IsNil(p.MarkComplete()))
+ // qt.Assert(t, qt.IsFalse(p.GetIsComplete()))
n, err := p.ReadAt(make([]byte, 1), 0)
- require.Error(t, err)
- require.EqualValues(t, 0, n)
- require.False(t, p.Completion().Complete)
+ qt.Check(t, qt.Not(qt.IsNil(err)))
+ qt.Check(t, qt.Equals(n, int(0)))
+ qt.Check(t, qt.IsFalse(p.Completion().Complete))
}
func TestMarkedCompleteMissingOnReadFile(t *testing.T) {
"context"
"testing"
- qt "github.com/frankban/quicktest"
+ "github.com/go-quicktest/qt"
"github.com/anacrolix/torrent/internal/testutil"
)
func TestMmapWindows(t *testing.T) {
- c := qt.New(t)
dir, mi := testutil.GreetingTestTorrent()
cs := NewMMap(dir)
defer func() {
- c.Check(cs.Close(), qt.IsNil)
+ qt.Check(t, qt.IsNil(cs.Close()))
}()
info, err := mi.UnmarshalInfo()
- c.Assert(err, qt.IsNil)
+ qt.Assert(t, qt.IsNil(err))
ts, err := cs.OpenTorrent(context.Background(), &info, mi.HashInfoBytes())
- c.Assert(err, qt.IsNil)
+ qt.Assert(t, qt.IsNil(err))
defer func() {
- c.Check(ts.Close(), qt.IsNil)
+ qt.Check(t, qt.IsNil(ts.Close()))
}()
}
"path/filepath"
"testing"
- qt "github.com/frankban/quicktest"
+ "github.com/go-quicktest/qt"
"github.com/anacrolix/torrent/metainfo"
)
// Check that safe file path handling still exists for the newer file-opt-maker variants.
func TestFileOptsSafeFilePathHandling(t *testing.T) {
- c := qt.New(t)
for i, _case := range safeFilePathTests {
- c.Run(fmt.Sprintf("Case%v", i), func(c *qt.C) {
+ t.Run(fmt.Sprintf("Case%v", i), func(t *testing.T) {
info := metainfo.Info{
Files: []metainfo.FileInfo{
{Path: _case.input},
client := NewFileOpts(NewFileClientOpts{
ClientBaseDir: t.TempDir(),
})
- defer func() { c.Check(client.Close(), qt.IsNil) }()
+ defer func() { qt.Assert(t, qt.IsNil(client.Close())) }()
torImpl, err := client.OpenTorrent(context.Background(), &info, metainfo.Hash{})
if _case.expectErr {
- c.Check(err, qt.Not(qt.IsNil))
+ qt.Check(t, qt.Not(qt.IsNil(err)))
} else {
- c.Check(torImpl.Close(), qt.IsNil)
+ qt.Check(t, qt.IsNil(torImpl.Close()))
}
})
}