From 64848a206a2ad338ce9ddc9387d85e00724e849b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 3 Aug 2015 16:23:05 +1000 Subject: [PATCH] Replace go-check with testify It's muuuuch better. --- client_test.go | 11 +++++------ connection_test.go | 14 ++++---------- misc_test.go | 12 ++++++++---- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/client_test.go b/client_test.go index 13e7ac8e..5e416fb4 100644 --- a/client_test.go +++ b/client_test.go @@ -17,7 +17,6 @@ import ( "github.com/bradfitz/iter" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/check.v1" "github.com/anacrolix/torrent/bencode" "github.com/anacrolix/torrent/data" @@ -308,21 +307,21 @@ func TestReadaheadPieces(t *testing.T) { } } -func (suite) TestMergingTrackersByAddingSpecs(c *check.C) { +func TestMergingTrackersByAddingSpecs(t *testing.T) { cl, _ := NewClient(&TestingConfig) defer cl.Close() spec := TorrentSpec{} T, new, _ := cl.AddTorrentSpec(&spec) if !new { - c.FailNow() + t.FailNow() } spec.Trackers = [][]string{{"http://a"}, {"udp://b"}} _, new, _ = cl.AddTorrentSpec(&spec) if new { - c.FailNow() + t.FailNow() } - c.Assert(T.Trackers[0][0].URL(), check.Equals, "http://a") - c.Assert(T.Trackers[1][0].URL(), check.Equals, "udp://b") + assert.EqualValues(t, T.Trackers[0][0].URL(), "http://a") + assert.EqualValues(t, T.Trackers[1][0].URL(), "udp://b") } type badData struct { diff --git a/connection_test.go b/connection_test.go index 1ffb9aef..3749a6ca 100644 --- a/connection_test.go +++ b/connection_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/bradfitz/iter" - . "gopkg.in/check.v1" + "github.com/stretchr/testify/assert" "github.com/anacrolix/torrent/internal/pieceordering" "github.com/anacrolix/torrent/peer_protocol" @@ -60,18 +60,12 @@ func pieceOrderingAsSlice(po *pieceordering.Instance) (ret []int) { return } -func testRequestOrder(expected []int, ro *pieceordering.Instance, t *C) { - t.Assert(pieceOrderingAsSlice(ro), DeepEquals, expected) +func testRequestOrder(expected []int, ro *pieceordering.Instance, t *testing.T) { + assert.EqualValues(t, pieceOrderingAsSlice(ro), expected) } -type suite struct{} - -var _ = Suite(suite{}) - -func Test(t *testing.T) { TestingT(t) } - // Tests the request ordering based on a connections priorities. -func (suite) TestPieceRequestOrder(t *C) { +func TestPieceRequestOrder(t *testing.T) { c := connection{ pieceRequestOrder: pieceordering.New(), piecePriorities: []int{1, 4, 0, 3, 2}, diff --git a/misc_test.go b/misc_test.go index 55cd3c66..17ee3133 100644 --- a/misc_test.go +++ b/misc_test.go @@ -1,12 +1,16 @@ package torrent -import . "gopkg.in/check.v1" +import ( + "testing" -func (suite) TestTorrentOffsetRequest(c *C) { + "github.com/stretchr/testify/assert" +) + +func TestTorrentOffsetRequest(t *testing.T) { check := func(tl, ps, off int64, expected request, ok bool) { req, _ok := torrentOffsetRequest(tl, ps, defaultChunkSize, off) - c.Check(_ok, Equals, ok) - c.Check(req, Equals, expected) + assert.Equal(t, _ok, ok) + assert.Equal(t, req, expected) } check(13, 5, 0, newRequest(0, 0, 5), true) check(13, 5, 3, newRequest(0, 0, 5), true) -- 2.44.0