2014-06-28 09:40:39 +00:00
|
|
|
package metainfo
|
2012-06-27 20:26:56 +00:00
|
|
|
|
|
|
|
import "testing"
|
|
|
|
import "path"
|
|
|
|
|
|
|
|
func test_file(t *testing.T, filename string) {
|
2012-07-01 19:05:10 +00:00
|
|
|
mi, err := LoadFromFile(filename)
|
2012-06-27 20:26:56 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2014-07-13 07:36:06 +00:00
|
|
|
if len(mi.Info.Files) == 1 {
|
|
|
|
t.Logf("Single file: %s (length: %d)\n", mi.Info.Name, mi.Info.Files[0].Length)
|
2012-07-10 20:30:05 +00:00
|
|
|
} else {
|
2014-07-13 07:36:06 +00:00
|
|
|
t.Logf("Multiple files: %s\n", mi.Info.Name)
|
|
|
|
for _, f := range mi.Info.Files {
|
2012-06-27 20:26:56 +00:00
|
|
|
t.Logf(" - %s (length: %d)\n", path.Join(f.Path...), f.Length)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-01 19:05:10 +00:00
|
|
|
for _, group := range mi.AnnounceList {
|
2012-06-27 20:26:56 +00:00
|
|
|
for _, tracker := range group {
|
|
|
|
t.Logf("Tracker: %s\n", tracker)
|
|
|
|
}
|
|
|
|
}
|
2014-07-13 07:36:06 +00:00
|
|
|
// for _, url := range mi.WebSeedURLs {
|
|
|
|
// t.Logf("URL: %s\n", url)
|
|
|
|
// }
|
2012-06-27 20:26:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFile(t *testing.T) {
|
|
|
|
test_file(t, "_testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent")
|
|
|
|
test_file(t, "_testdata/continuum.torrent")
|
|
|
|
}
|