mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
120 lines
12 KiB
Go
120 lines
12 KiB
Go
// Copyright (c) 2021-2025, Ludvig Lundgren and the autobrr contributors.
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
package domain
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRejectionReasons_String(t *testing.T) {
|
|
t.Parallel()
|
|
type fields struct {
|
|
data []Rejection
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
want string
|
|
}{
|
|
{
|
|
name: "empty",
|
|
fields: fields{
|
|
data: []Rejection{},
|
|
},
|
|
want: "",
|
|
},
|
|
{
|
|
name: "non_empty",
|
|
fields: fields{
|
|
data: []Rejection{
|
|
{
|
|
key: "resolution",
|
|
got: "1080p",
|
|
want: "2160p",
|
|
},
|
|
{
|
|
key: "match hdr",
|
|
got: []string{"HDR10"},
|
|
want: []string{"DV"},
|
|
},
|
|
},
|
|
},
|
|
want: "[resolution] not matching: got 1080p want: 2160p, [match hdr] not matching: got [HDR10] want: [DV]",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := &RejectionReasons{
|
|
data: tt.fields.data,
|
|
}
|
|
assert.Equalf(t, tt.want, r.String(), "String()")
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRejectionReasons_StringTruncated(t *testing.T) {
|
|
t.Parallel()
|
|
type fields struct {
|
|
data []Rejection
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
want string
|
|
}{
|
|
{
|
|
name: "empty",
|
|
fields: fields{
|
|
data: []Rejection{},
|
|
},
|
|
want: "",
|
|
},
|
|
{
|
|
name: "non_empty",
|
|
fields: fields{
|
|
data: []Rejection{
|
|
{
|
|
key: "resolution",
|
|
got: "1080p",
|
|
want: "2160p",
|
|
},
|
|
{
|
|
key: "match hdr",
|
|
got: []string{"HDR10"},
|
|
want: []string{"DV"},
|
|
},
|
|
},
|
|
},
|
|
want: "[resolution] not matching: got 1080p want: 2160p, [match hdr] not matching: got [HDR10] want: [DV]",
|
|
},
|
|
{
|
|
name: "truncated",
|
|
fields: fields{
|
|
data: []Rejection{
|
|
{
|
|
key: "resolution",
|
|
got: "1080p",
|
|
want: "2160p",
|
|
},
|
|
{
|
|
key: "match description",
|
|
got: "Kategori: Music \\n Storlek: 132.78 MiB\\n ? ?? ?? ????????? ?? ?? ?? ?? ?? ???? ?? ?? ?? ???? ??? ? ?? ?? ?? ? ??? ? ? ?? ? ?? ? ??? ? ?? ?? ??? ?? ?? ???? ???? ?? ???? ????? ????? ? ?? ?? ???? ?? ???? ?? ?? ? ?????? ????????????? ???????????? ????????????? ?????? ???? ?????? ? ?? ??? ? ?? ? ?? ?? ??? ?? ? ? ?????? ?? ?? ?? ?? ?? ????? ? ?? ?? ?? ?? ?? ????????? ? ?????? ?? ????????? ??? ? ?????? ? ?? ? ?? ?? ??? ? ? ? ?? ?? ? ??? ? ?? ? ? ?? ????? ? ?? ? ? ?? ?? ??? ??? ??? ?? ??? ?? ??? ??? ? ????????? ???? ?? ????? ? ?? ????????????? ??????????? ??? ???? ??? ?? ?????????? ?? ?? ??? ?? ??? ??? ???? ??? ? ?? ??? ? ?? ?????????? ?? ??????????????? ????????????? ???? ???? ????? ??? ??????? ???????? ????? ???????? ????? ????? ?? ??? ??? ? ? ???? ???? ???? ???? ???? ???? ???? ?? ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?? ?? ??? ??? ?? ??? ??? ??? ??? ??? ???????? ? ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?????? ??? ??? ???? ??? ? ??? ??? ??? ??? ? ??? ???? ? ? ??? ???? ???? ?? ?? ?? ?? ?? ?? ?? ??????? ???? ???? ? ?? ? ? ? ? ? ? ?????? ??????? ????? ?? ? ? ? ? ? ? ?? ?????? ????? ?? ? ? ? ? ? ? sM!iMPURE ??? ???? ? ? ? ? ? ? ./\\\\\\\\//\\\\\\\\. ???? ?? ? ? ? ?? ? ? ? ? ?????????????????????????????????????? ?????????????????? ?????????????????? ??? ?? ?? ??? ??? RELEASE INFORMATION for: ??? ?? Portae_Obscuritas-Sapientia_Occulta-WEB-2024-ENTiTLED ?? ?? ?? ? artist........ | Portae Obscuritas ? title......... | Sapientia Occulta label......... | 6868317 Records DK genre......... | Black Metal url............| https://www.deezer.com/album/568832371 rip date...... | 2024-10-17 retail date... | 2024-04-03 runtime....... | 55:41 tracks........ | 7 size.......... | 132.14MB source........ | WEB quality....... | CBR 320kbps 44.1kHz Stereo ? codec......... | MP3 (MPEG-1 Audio Layer 3) ? ?? encoder....... | LAME ?? ?? ?? ?? ?? ???? ???? ?????????????????? ?????????????????? ??? ? ?????????????????????????????????????? ? ?? ?? ?? ???? ------------------------------------------- ???? ??? ? ?\\u003c t r a c k . l i s t \\u003e? ? ??? ?? ------------------------------------------- ??? ?? ?? ?? ?? 01 \\u003e Intro \\u003c 05:12 02 \\u003e In a Twilight Obscurity \\u003c 09:15 03 \\u003e Manifestation of Acheronian Trinity \\u003c 09:14 04 \\u003e Imperious Reverent Transcendence \\u003c 08:59 05 \\u003e Enslaved Spirit of Forgotten Kingdoms \\u003c 11:48 06 \\u003e Sapientia Occulta \\u003c 08:24 07 \\u003e Outro \\u003c 02:49 ? ? ?? ?? ?? ?? ?? ?? ???? ???? ? ?????????????????? ?????????????????? ? ??? ?????????????????????????????????????? ??? ??? ??? ? ? ?\\u003c GREETINGS \\u003e? ? ? ?% %? ?? ?? ?% %? ?? Shout out to all of those who keep the dream of the scene alive. ?? ?% %? ?? Special thanks to those who have paved the way and parted. ?? ?% %? ?? We miss you! ?? ?% %? ?? ?? ?% %? ?? ?? ?% %? ?? ?? ?% %? ?? ?? ?% ??????????? %? ??? ?????? ????????? ?????? ??? ??? ? ?????????????? ? ??????????????? ? ??? ? ???????????????? ?????????????? ????? ???????????? ????????????????? ? ??????? ??????? ????? ??? ? ??? ?????? ??????? ??????? ?? ???????? ? ?????? ???? ? ???? ?????? ? ??????? ?? ?? ??????????? ??? ??????????? ?? ?? ?? + ? + ?? ?? ? ???? o ????? ? ????????????? ? ? ? ? ??? ??? ? ? ? ? ? ? ? ? ???? ????",
|
|
want: "*black?metal*",
|
|
},
|
|
},
|
|
},
|
|
want: "[resolution] not matching: got 1080p want: 2160p, [match description] not matching: got Kategori: Music \\n Storlek: 132.78 MiB\\n ? ?? ?? ????????? ?? ?? ?? ?? ?? ???? ?? ?? ?? ???? ??? ? ?? ?? ?? ? ??? ? ? ?? ? ?? ? ??? ? ?? ?? ??? ?? ?? ???? ???? ?? ???? ????? ????? ? ?? ?? ???? ?? ???? ?? ?? ? ?????? ????????????? ???????????? ????????????? ?????? ???? ?????? ? ?? ??? ? ?? ? ?? ?? ??? ?? ? ? ?????? ?? ?? ?? ?? ?? ????? ? ?? want: *black?metal*",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := &RejectionReasons{
|
|
data: tt.fields.data,
|
|
}
|
|
assert.Equalf(t, tt.want, r.StringTruncated(), "StringTruncated()")
|
|
})
|
|
}
|
|
}
|