feat(macros): add SizeString DownloadURL and InfoURL (#1080)

* feat(macro): add new variables

* SizeString
* DownloadURL
* InfoURL

* feat(macro): add new test cases
This commit is contained in:
ze0s 2023-09-03 13:27:47 +02:00 committed by GitHub
parent 63660946eb
commit 1bfbe38335
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 86 additions and 52 deletions

View file

@ -89,7 +89,7 @@ func TestMacros_Parse(t *testing.T) {
name: "test_args_long",
release: Release{
TorrentName: "This movie 2021",
TorrentURL: "https://some.site/download/fakeid",
DownloadURL: "https://some.site/download/fakeid",
Indexer: "mock1",
},
args: args{text: "{{.TorrentName}} {{.TorrentUrl}} SOME_LONG_TOKEN"},
@ -100,7 +100,7 @@ func TestMacros_Parse(t *testing.T) {
name: "test_args_long_1",
release: Release{
TorrentName: "This movie 2021",
TorrentURL: "https://some.site/download/fakeid",
DownloadURL: "https://some.site/download/fakeid",
Indexer: "mock1",
},
args: args{text: "{{.Indexer}} {{.TorrentName}} {{.TorrentUrl}} SOME_LONG_TOKEN"},
@ -111,7 +111,7 @@ func TestMacros_Parse(t *testing.T) {
name: "test_args_category",
release: Release{
TorrentName: "This movie 2021",
TorrentURL: "https://some.site/download/fakeid",
DownloadURL: "https://some.site/download/fakeid",
Indexer: "mock1",
},
args: args{text: "{{.Indexer}}-race"},
@ -122,7 +122,7 @@ func TestMacros_Parse(t *testing.T) {
name: "test_args_category_year",
release: Release{
TorrentName: "This movie 2021",
TorrentURL: "https://some.site/download/fakeid",
DownloadURL: "https://some.site/download/fakeid",
Indexer: "mock1",
},
args: args{text: "{{.Indexer}}-{{.CurrentYear}}-race"},
@ -133,7 +133,7 @@ func TestMacros_Parse(t *testing.T) {
name: "test_args_category_year",
release: Release{
TorrentName: "This movie 2021",
TorrentURL: "https://some.site/download/fakeid",
DownloadURL: "https://some.site/download/fakeid",
Indexer: "mock1",
Resolution: "2160p",
HDR: []string{"DV"},
@ -146,7 +146,7 @@ func TestMacros_Parse(t *testing.T) {
name: "test_args_category_and_if",
release: Release{
TorrentName: "This movie 2021",
TorrentURL: "https://some.site/download/fakeid",
DownloadURL: "https://some.site/download/fakeid",
Indexer: "mock1",
Resolution: "2160p",
HDR: []string{"HDR"},
@ -159,7 +159,7 @@ func TestMacros_Parse(t *testing.T) {
name: "test_release_year_1",
release: Release{
TorrentName: "This movie 2021",
TorrentURL: "https://some.site/download/fakeid",
DownloadURL: "https://some.site/download/fakeid",
Indexer: "mock1",
Resolution: "2160p",
HDR: []string{"HDR"},
@ -178,6 +178,15 @@ func TestMacros_Parse(t *testing.T) {
want: "3.57 GB",
wantErr: false,
},
{
name: "test_size_string",
release: Release{
Size: 3834225472,
},
args: args{text: "Size: {{ .SizeString }}"},
want: "Size: 3.8 GB",
wantErr: false,
},
{
name: "test_text_manipulation",
release: Release{
@ -187,6 +196,24 @@ func TestMacros_Parse(t *testing.T) {
want: "[Blu-ray][MKV][h264 10-bit][1080p][FLAC 2.0][Dual Audio][Softsubs (Sub Group)][Freeleech]",
wantErr: false,
},
{
name: "test_info_url",
release: Release{
InfoURL: "https://test.local/this/page",
},
args: args{text: "InfoUrl: {{ .InfoUrl }}"},
want: "InfoUrl: https://test.local/this/page",
wantErr: false,
},
{
name: "test_download_url",
release: Release{
DownloadURL: "https://test.local/this/page/1001",
},
args: args{text: "DownloadUrl: {{ .DownloadUrl }}"},
want: "DownloadUrl: https://test.local/this/page/1001",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {