You've already forked torrent-client
mirror of
https://github.com/veggiedefender/torrent-client.git
synced 2025-11-06 09:29:16 +02:00
Rename toTorrent to toTorrentFile
This commit is contained in:
@@ -72,11 +72,7 @@ func Open(r io.Reader) (*TorrentFile, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
t, err := bto.toTorrent()
|
return bto.toTorrentFile()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return t, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *bencodeInfo) hash() ([20]byte, error) {
|
func (i *bencodeInfo) hash() ([20]byte, error) {
|
||||||
@@ -105,7 +101,7 @@ func (i *bencodeInfo) splitPieceHashes() ([][20]byte, error) {
|
|||||||
return hashes, nil
|
return hashes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bto *bencodeTorrent) toTorrent() (*TorrentFile, error) {
|
func (bto *bencodeTorrent) toTorrentFile() (*TorrentFile, error) {
|
||||||
infoHash, err := bto.Info.hash()
|
infoHash, err := bto.Info.hash()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func TestOpen(t *testing.T) {
|
|||||||
assert.Equal(t, expected, torrent)
|
assert.Equal(t, expected, torrent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestToTorrent(t *testing.T) {
|
func TestToTorrentFile(t *testing.T) {
|
||||||
tests := map[string]struct {
|
tests := map[string]struct {
|
||||||
input *bencodeTorrent
|
input *bencodeTorrent
|
||||||
output *TorrentFile
|
output *TorrentFile
|
||||||
@@ -81,7 +81,7 @@ func TestToTorrent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
to, err := test.input.toTorrent()
|
to, err := test.input.toTorrentFile()
|
||||||
if test.fails {
|
if test.fails {
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user