ci / module boundaries / boundaries (push) Successful in 7s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 55s
ci / ts / ts (packages + web) (push) Failing after 4m4s
ci / api / api (push) Successful in 55s
ci / db / db (push) Failing after 1m14s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m11s
23 lines
1.4 KiB
Go
23 lines
1.4 KiB
Go
package meta
|
|
|
|
import "testing"
|
|
|
|
func TestSuggestFromSamplesUsesDominantLayoutWithoutRegexes(t *testing.T) {
|
|
samples := []TemplateSample{
|
|
{RelPath: "Кино/Группа крови (1988)/01. Группа крови.flac", Input: in(Fields{Artist: "Кино", Album: "Группа крови", Title: "Группа крови", Year: "1988", Track: "1"}, 1, "flac")},
|
|
{RelPath: "Кино/Группа крови (1988)/02. Закрой за мной дверь.flac", Input: in(Fields{Artist: "Кино", Album: "Группа крови", Title: "Закрой за мной дверь", Year: "1988", Track: "2"}, 1, "flac")},
|
|
{RelPath: "Queen/Jazz (1978)/03. Jealousy.mp3", Input: in(Fields{Artist: "Queen", Album: "Jazz", Title: "Jealousy", Year: "1978", Track: "3"}, 1, "mp3")},
|
|
{RelPath: "Other - Song.flac", Input: in(Fields{Artist: "Other", Album: "Single", Title: "Song"}, 1, "flac")},
|
|
}
|
|
got, err := SuggestFromSamples(nil, samples)
|
|
if err != nil || got.Template != "{albumartist}/{album} ({year})/{track:02}. {title}.{ext}" || got.Matched != 3 || got.Total != 4 || len(got.Examples) != 3 {
|
|
t.Fatalf("suggestion = %+v, err = %v", got, err)
|
|
}
|
|
}
|
|
|
|
func TestSuggestFromSamplesDoesNotGuessWithoutMetadata(t *testing.T) {
|
|
if _, err := SuggestFromSamples(nil, []TemplateSample{{RelPath: "unknown/file.flac"}}); err == nil {
|
|
t.Fatal("cannot infer a safe layout without matching metadata")
|
|
}
|
|
}
|