-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtpb_test.go
43 lines (36 loc) · 1.1 KB
/
tpb_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package imdb2torrent
import (
"context"
"fmt"
"strings"
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
)
func TestTPBMovie(t *testing.T) {
imdbID := "tt0063350" // Night of the Living Dead, 1968, public domain
cache := NewInMemoryCache()
metaGetter := &metaGetterMock{
t: t,
expIMDBID: imdbID,
meta: Meta{
Title: "Night of the Living Dead",
Year: 1968,
},
}
logger := zap.NewNop()
client, err := NewTPBclient(DefaultTPBclientOpts, cache, metaGetter, logger, false)
require.NoError(t, err)
torrents, err := client.FindMovie(context.Background(), imdbID)
require.NoError(t, err)
require.NotEmpty(t, torrents)
firstElem := torrents[0]
fmt.Printf("TPB result first elem: %+v\n", firstElem)
require.NotEmpty(t, firstElem.Name)
require.Len(t, firstElem.InfoHash, 40)
require.True(t, strings.HasPrefix(firstElem.MagnetURL, "magnet:?xt=urn:btih:"+firstElem.InfoHash))
require.Regexp(t, qualityRegex, firstElem.Quality)
require.Equal(t, firstElem.Title, "Night of the Living Dead")
require.Greater(t, firstElem.Size, 0)
require.Greater(t, firstElem.Seeders, 0)
}