2014-06-28 17:40:39 +08:00
|
|
|
package metainfo
|
2012-06-28 04:26:56 +08:00
|
|
|
|
|
|
|
import "testing"
|
|
|
|
import "path"
|
|
|
|
|
|
|
|
func test_file(t *testing.T, filename string) {
|
2012-07-02 03:05:10 +08:00
|
|
|
mi, err := LoadFromFile(filename)
|
2012-06-28 04:26:56 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2014-07-13 15:36:06 +08: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-11 04:30:05 +08:00
|
|
|
} else {
|
2014-07-13 15:36:06 +08:00
|
|
|
t.Logf("Multiple files: %s\n", mi.Info.Name)
|
|
|
|
for _, f := range mi.Info.Files {
|
2012-06-28 04:26:56 +08:00
|
|
|
t.Logf(" - %s (length: %d)\n", path.Join(f.Path...), f.Length)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-02 03:05:10 +08:00
|
|
|
for _, group := range mi.AnnounceList {
|
2012-06-28 04:26:56 +08:00
|
|
|
for _, tracker := range group {
|
|
|
|
t.Logf("Tracker: %s\n", tracker)
|
|
|
|
}
|
|
|
|
}
|
2014-07-13 15:36:06 +08:00
|
|
|
// for _, url := range mi.WebSeedURLs {
|
|
|
|
// t.Logf("URL: %s\n", url)
|
|
|
|
// }
|
2012-06-28 04:26:56 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFile(t *testing.T) {
|
|
|
|
test_file(t, "_testdata/archlinux-2011.08.19-netinstall-i686.iso.torrent")
|
|
|
|
test_file(t, "_testdata/continuum.torrent")
|
|
|
|
}
|