package converter import "testing" func TestExtractAlbumFolder(t *testing.T) { tests := []struct { m *message albumFolder string }{ {createMessage("/test/artistX", "/test/artistX/albumY/songX.flac"), "albumY"}, {createMessage("/test/artistX/", "/test/artistX/album Y/songX.flac"), "album Y"}, } for _, tt := range tests { actual := tt.m.extractAlbumFolder() expected := tt.albumFolder if actual != expected { t.Errorf("expected %v, got %v", expected, actual) } } } func createMessage(artistPath, filePath string) *message { return &message{ Artist: artist{ Path: artistPath, }, TrackFiles: []trackFile{ { Path: filePath, }, }, } }