<commit_before>package podcasts

import (
	"bytes"
	"encoding/xml"
	"testing"

	"github.com/stretchr/testify/suite"
)

type validFeed struct {
	Channel struct {
		Title string `xml:"title"`
	} `xml:"channel"`
}

type PodcastsTestSuite struct {
	suite.Suite
	podcast *Podcast
}

func (s *PodcastsTestSuite) SetupTest() {
	title := "test TITLE"
	desc := "description"
	lang := "lang"
	link := "link"
	copyright := "copyright"

	s.podcast = &Podcast{
		Title:       title,
		Description: desc,
		Language:    lang,
		Link:        link,
		Copyright:   copyright,
	}
}

func (s *PodcastsTestSuite) TestPodcastFeedXml() {
	feed, err := s.podcast.Feed()
	s.Nil(err)

	data, err := feed.XML()
	s.Nil(err)

	vf := validFeed{}
	err = xml.Unmarshal([]byte(data), &vf)

	s.Nil(err)
	s.Equal(s.podcast.Title, vf.Channel.Title)
}

func (s *PodcastsTestSuite) TestPodcastFeedWrite() {
	feed, err := s.podcast.Feed()
	s.Nil(err)

	var b bytes.Buffer
	err = feed.Write(&b)
	s.Nil(err)
}

func TestPodcastsTestSuite(t *testing.T) {
	suite.Run(t, new(PodcastsTestSuite))
}<commit_msg>update tests<commit_after>package podcasts

import (
	"bytes"
	"fmt"
	"testing"

	"github.com/stretchr/testify/suite"
)

type PodcastsTestSuite struct {
	suite.Suite
	podcast *Podcast
}

func (s *PodcastsTestSuite) SetupTest() {
	s.podcast = &Podcast{
		Title:       "my podcast title",
		Description: "my podcast description",
		Language:    "my podcast lang",
		Link:        "my podcast link",
		Copyright:   "my podcast copyright",
	}
}

func (s *PodcastsTestSuite) TestContainsXmlHeader() {
	data, err := getPodcastXML(s.podcast)

	s.Nil(err)
	s.Contains(data, `<?xml version="1.0" encoding="UTF-8"?>`)
}

func (s *PodcastsTestSuite) TestContainsRssElement() {
	data, err := getPodcastXML(s.podcast)

	s.Nil(err)
	s.Contains(data, `<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">`)
}

func (s *PodcastsTestSuite) TestContainsChannelElement() {
	data, err := getPodcastXML(s.podcast)

	s.Nil(err)
	s.Contains(data, `<channel>`)
	s.Contains(data, `</channel>`)
}

func (s *PodcastsTestSuite) TestContainsTitleElement() {
	data, err := getPodcastXML(s.podcast)

	s.Nil(err)
	s.Contains(data, fmt.Sprintf("<title>%s</title>", s.podcast.Title))
}

func (s *PodcastsTestSuite) TestContainsDescriptionElement() {
	data, err := getPodcastXML(s.podcast)

	s.Nil(err)
	s.Contains(data, fmt.Sprintf("<description>%s</description>", s.podcast.Description))
}

func (s *PodcastsTestSuite) TestContainsLanguageElement() {
	data, err := getPodcastXML(s.podcast)

	s.Nil(err)
	s.Contains(data, fmt.Sprintf("<language>%s</language>", s.podcast.Language))
}

func (s *PodcastsTestSuite) TestContainsLinkElement() {
	data, err := getPodcastXML(s.podcast)

	s.Nil(err)
	s.Contains(data, fmt.Sprintf("<link>%s</link>", s.podcast.Link))
}

func (s *PodcastsTestSuite) TestContainsCopyrightElement() {
	data, err := getPodcastXML(s.podcast)

	s.Nil(err)
	s.Contains(data, fmt.Sprintf("<copyright>%s</copyright>", s.podcast.Copyright))
}

func (s *PodcastsTestSuite) TestPodcastFeedWrite() {
	feed, err := s.podcast.Feed()
	s.Nil(err)

	var b bytes.Buffer
	err = feed.Write(&b)
	s.Nil(err)
}

func TestPodcastsTestSuite(t *testing.T) {
	suite.Run(t, new(PodcastsTestSuite))
}

func getPodcastXML(p *Podcast) (string, error) {
	feed, err := p.Feed()
	if err != nil {
		return "", err
	}
	return feed.XML()
}
{'fraction_non_alphanumeric': 0.16592724046140195, 'fraction_numerical': 0.002070393374741201, 'mean_word_length': 4.674496644295302, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 1, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1725126', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1286, 'n_words': 253}