mirror of
https://github.com/rumanzo/bt2qbt.git
synced 2024-11-22 10:22:38 +01:00
47e0028bc1
* Fix structures * torrents v2 file tree interface * get files vrom both v1 and v2 torrents * fix typo * style * cleanup makefile * new test fileset with real qBittorrent files and new tests * counting files using torrent file * Handle v2 and hybryd torrents
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package qBittorrentStructures
|
|
|
|
import (
|
|
"github.com/rumanzo/bt2qbt/pkg/helpers"
|
|
"testing"
|
|
)
|
|
|
|
func TestDecodeFastresumeFile(t *testing.T) {
|
|
type PathJoinCase struct {
|
|
name string
|
|
mustFail bool
|
|
path string
|
|
}
|
|
cases := []PathJoinCase{
|
|
{
|
|
name: "001 not existing file",
|
|
path: "notexists.fastresume",
|
|
mustFail: true,
|
|
},
|
|
{
|
|
name: "002 testdir hybryd",
|
|
path: "../../test/data/testdir_hybrid.fastresume",
|
|
},
|
|
{
|
|
name: "003 testdir v1",
|
|
path: "../../test/data/testdir_v1.fastresume",
|
|
},
|
|
{
|
|
name: "004 testdir v2",
|
|
path: "../../test/data/testdir_v2.fastresume",
|
|
},
|
|
{
|
|
name: "005 single hybryd",
|
|
path: "../../test/data/testfile1_single_hybrid.fastresume",
|
|
},
|
|
{
|
|
name: "006 single v1",
|
|
path: "../../test/data/testfile1_single_v1.fastresume",
|
|
},
|
|
{
|
|
name: "007 single v2",
|
|
path: "../../test/data/testfile1_single_v2.fastresume",
|
|
},
|
|
}
|
|
for _, testCase := range cases {
|
|
t.Run(testCase.name, func(t *testing.T) {
|
|
var decoded QBittorrentFastresume
|
|
err := helpers.DecodeTorrentFile(testCase.path, &decoded)
|
|
if err != nil && !testCase.mustFail {
|
|
t.Fatalf("Unexpected error: %v", err)
|
|
} else if err == nil && testCase.mustFail {
|
|
t.Fatalf("Test must fail, but it doesn't")
|
|
}
|
|
})
|
|
}
|
|
}
|