diff options
| -rw-r--r-- | schema/schema.go | 4 | ||||
| -rw-r--r-- | schema/schema_test.go | 30 |
2 files changed, 34 insertions, 0 deletions
diff --git a/schema/schema.go b/schema/schema.go index 7ef5c99..4cc79af 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -88,3 +88,7 @@ type PodcastFeed struct { func (e Entry) TitleContains(contains string) bool { return strings.Contains(strings.ToLower(e.Title), strings.ToLower(contains)) } + +func (e Entry) DescContains(contains string) bool { + return strings.Contains(strings.ToLower(e.Desc), strings.ToLower(contains)) +} diff --git a/schema/schema_test.go b/schema/schema_test.go index aee2452..5dc00d1 100644 --- a/schema/schema_test.go +++ b/schema/schema_test.go @@ -114,3 +114,33 @@ func TestYoutubeFeed(t *testing.T) { } } +func TestEntryDescContains(t *testing.T) { + var testMatrix = []struct { + name string + entry Entry + contains string + expected bool + }{ + { + name: "t1", + entry: Entry{ + Desc: "iPhone 1 through 17 generation takes the same photo", + }, + contains: "iPhone", + expected: true, + }, + { + name: "t2", + entry: Entry{ + Desc: "iPhone 1 through 17 generation takes the same photo", + }, + contains: "iPhone 17", + expected: false, + }, + } + for _, tc := range testMatrix { + if tc.entry.DescContains(tc.contains) != tc.expected { + t.Errorf("%s: expected %v, got %v", tc.name, tc.expected, !tc.expected) + } + } +} |
