From 31aa0d666b80c8ce6a9d3e601b1a2cd06f2edc7f Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Tue, 29 Sep 2015 20:13:14 -0700 Subject: [PATCH] add torrent test for binary data --- torrent_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/torrent_test.go b/torrent_test.go index 6d9afbb..5a1d34a 100644 --- a/torrent_test.go +++ b/torrent_test.go @@ -44,4 +44,19 @@ func TestCreateTorrent(t *testing.T) { } } +func TestCreateTorrentWithImage(t *testing.T) { + var decoded Torrent + + encoded, err := CreateTorrent("test.jpg", "static/images/404.jpg") + if err != nil { + t.Fatal(err) + } + + bencode.DecodeBytes(encoded, &decoded) + + if decoded.Info.Pieces != "r\x01\x80j\x99\x84\n\xd3dZ;1NX\xec;\x9d$+f" { + t.Fatal("Torrent pieces did not match expected pieces for image") + } +} + // vim:set ts=8 sw=8 noet: