mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(macros): add IndexerName
(#1511)
* feat(macros): add IndexerName * fix: tests * fix: tests
This commit is contained in:
parent
c43e2c76d6
commit
3c3b47fa10
37 changed files with 310 additions and 235 deletions
|
@ -36,7 +36,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "Print mee {{.TorrentPathName}}"},
|
||||
want: "Print mee /tmp/a-temporary-file.torrent",
|
||||
|
@ -47,7 +47,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "Print mee {{TorrentPathName}}"},
|
||||
want: "",
|
||||
|
@ -58,7 +58,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "add {{.TorrentPathName}} --category test"},
|
||||
want: "add /tmp/a-temporary-file.torrent --category test",
|
||||
|
@ -68,7 +68,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
name: "test_program_arg_bad",
|
||||
release: Release{
|
||||
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "add {{.TorrenttPathName}} --category test"},
|
||||
want: "",
|
||||
|
@ -79,7 +79,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
TorrentTmpFile: "/tmp/a-temporary-file.torrent",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "add {{.TorrentPathName}} --category test --other {{.TorrentName}}"},
|
||||
want: "add /tmp/a-temporary-file.torrent --category test --other This movie 2021",
|
||||
|
@ -90,7 +90,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
DownloadURL: "https://some.site/download/fakeid",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "{{.TorrentName}} {{.TorrentUrl}} SOME_LONG_TOKEN"},
|
||||
want: "This movie 2021 https://some.site/download/fakeid SOME_LONG_TOKEN",
|
||||
|
@ -101,7 +101,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
DownloadURL: "https://some.site/download/fakeid",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "{{.Indexer}} {{.TorrentName}} {{.TorrentUrl}} SOME_LONG_TOKEN"},
|
||||
want: "mock1 This movie 2021 https://some.site/download/fakeid SOME_LONG_TOKEN",
|
||||
|
@ -112,7 +112,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
DownloadURL: "https://some.site/download/fakeid",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "{{.Indexer}}-race"},
|
||||
want: "mock1-race",
|
||||
|
@ -123,7 +123,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
DownloadURL: "https://some.site/download/fakeid",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "{{.Indexer}}-{{.CurrentYear}}-race"},
|
||||
want: fmt.Sprintf("mock1-%v-race", currentTime.Year()),
|
||||
|
@ -134,7 +134,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
DownloadURL: "https://some.site/download/fakeid",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
Resolution: "2160p",
|
||||
HDR: []string{"DV"},
|
||||
},
|
||||
|
@ -147,7 +147,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
DownloadURL: "https://some.site/download/fakeid",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
Resolution: "2160p",
|
||||
HDR: []string{"HDR"},
|
||||
},
|
||||
|
@ -160,7 +160,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
release: Release{
|
||||
TorrentName: "This movie 2021",
|
||||
DownloadURL: "https://some.site/download/fakeid",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
Resolution: "2160p",
|
||||
HDR: []string{"HDR"},
|
||||
Year: 2021,
|
||||
|
@ -220,7 +220,7 @@ func TestMacros_Parse(t *testing.T) {
|
|||
TorrentName: "This movie 2021",
|
||||
DownloadURL: "https://some.site/download/fakeid",
|
||||
Group: "thisgrp",
|
||||
Indexer: "mock1",
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
Year: 2021,
|
||||
},
|
||||
args: args{text: "movies-{{.Group}}"},
|
||||
|
@ -263,6 +263,15 @@ func TestMacros_Parse(t *testing.T) {
|
|||
want: "Artists: Jon Boy",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "test_args_indexer",
|
||||
release: Release{
|
||||
Indexer: IndexerMinimal{0, "Mock Indexer", "mock1"},
|
||||
},
|
||||
args: args{text: "indexer={{.IndexerName}}"},
|
||||
want: fmt.Sprintf("indexer=Mock Indexer"),
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue