1
0
mirror of https://github.com/mxpv/podsync.git synced 2024-05-11 05:55:04 +00:00
mxpv-podsync/pkg/feed/xml_test.go

49 lines
1.3 KiB
Go
Raw Normal View History

2020-10-04 14:00:51 -07:00
package feed
import (
"context"
"testing"
itunes "github.com/eduncan911/podcast"
2020-10-04 14:00:51 -07:00
"github.com/mxpv/podsync/pkg/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
2020-10-04 14:00:51 -07:00
)
func TestBuildXML(t *testing.T) {
feed := model.Feed{
Episodes: []*model.Episode{
{
ID: "1",
Status: model.EpisodeDownloaded,
Title: "title",
Description: "description",
},
},
}
2020-10-04 14:00:51 -07:00
2022-01-02 14:57:10 +02:00
cfg := Config{
ID: "test",
2022-01-02 14:57:10 +02:00
Custom: Custom{Description: "description", Category: "Technology", Subcategories: []string{"Gadgets", "Podcasting"}},
2020-10-04 14:00:51 -07:00
}
out, err := Build(context.Background(), &feed, &cfg, "http://localhost/")
2020-10-04 14:00:51 -07:00
assert.NoError(t, err)
assert.EqualValues(t, "description", out.Description)
assert.EqualValues(t, "Technology", out.Category)
require.Len(t, out.ICategories, 1)
category := out.ICategories[0]
assert.EqualValues(t, "Technology", category.Text)
2020-10-04 14:00:51 -07:00
require.Len(t, category.ICategories, 2)
assert.EqualValues(t, "Gadgets", category.ICategories[0].Text)
assert.EqualValues(t, "Podcasting", category.ICategories[1].Text)
require.Len(t, out.Items, 1)
require.NotNil(t, out.Items[0].Enclosure)
assert.EqualValues(t, out.Items[0].Enclosure.URL, "http://localhost/test/1.mp4")
assert.EqualValues(t, out.Items[0].Enclosure.Type, itunes.MP4)
2020-10-04 14:00:51 -07:00
}