Replace go-check with testify

It's muuuuch better.
This commit is contained in:
Matt Joiner 2015-08-03 16:23:05 +10:00
parent 50ce70c47a
commit 64848a206a
3 changed files with 17 additions and 20 deletions

View File

@ -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 {

View File

@ -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},

View File

@ -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)