Podcast-focused library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

85 lines
1.3 KiB

package podcast_test
import (
"testing"
"github.com/arenzana/podcast"
"github.com/stretchr/testify/assert"
)
func TestItemAddSummaryTooLong(t *testing.T) {
t.Parallel()
// arrange
i := podcast.Item{
Title: "item.title",
Description: "item.desc",
Link: "http://example.com/article.html",
}
summary := ""
for {
if len(summary) >= 4051 {
break
}
summary += "abc ss 5 "
}
// act
i.AddSummary(summary)
// assert
assert.Len(t, i.ISummary.Text, 4000)
}
func TestItemAddImageEmptyUrl(t *testing.T) {
t.Parallel()
// arrange
i := podcast.Item{
Title: "item.title",
Description: "item.desc",
Link: "http://example.com/article.html",
}
// act
i.AddImage("")
// assert
assert.Nil(t, i.IImage)
}
func TestItemAddDurationZero(t *testing.T) {
t.Parallel()
// arrange
i := podcast.Item{
Title: "item.title",
Description: "item.desc",
Link: "http://example.com/article.html",
}
d := int64(0)
// act
i.AddDuration(d)
// assert
assert.EqualValues(t, "", i.IDuration)
}
func TestItemAddDurationLessThanZero(t *testing.T) {
t.Parallel()
// arrange
i := podcast.Item{
Title: "item.title",
Description: "item.desc",
Link: "http://example.com/article.html",
}
d := int64(-13)
// act
i.AddDuration(d)
// assert
assert.EqualValues(t, "", i.IDuration)
}