Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/service/torrent/metainfoFetcher/operation_test.go

45 lignes
827 o
Go
Brut Vue normale Historique

2017-05-17 07:58:40 +02:00
package metainfoFetcher
import (
"testing"
2017-05-17 07:58:40 +02:00
"github.com/NyaaPantsu/nyaa/model"
"github.com/anacrolix/torrent"
)
func TestInvalidHash(t *testing.T) {
client, err := torrent.NewClient(nil)
if err != nil {
t.Skipf("Failed to create client, with err %v. Skipping.", err)
}
2017-05-14 13:20:34 +02:00
fetcher := &MetainfoFetcher{
2017-05-17 07:58:40 +02:00
timeout: 5,
torrentClient: client,
2017-05-17 07:58:40 +02:00
results: make(chan Result, 1),
}
dbEntry := model.Torrent{
Hash: "INVALID",
Name: "Invalid",
}
op := NewFetchOperation(fetcher, dbEntry)
fetcher.wg.Add(1)
op.Start(fetcher.results)
var res Result
select {
case res = <-fetcher.results:
break
default:
t.Fatal("No result in channel, should have one")
}
if res.err == nil {
t.Fatal("Got no error, should have got invalid magnet")
}
t.Logf("Got error %s, shouldn't be timeout", res.err)
}