From 352d32119b0940d1590cdefef05d44dd75e94342 Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Wed, 1 Apr 2026 20:35:20 -0400 Subject: schema: add `Entry.DescContains` --- schema/schema.go | 4 ++++ schema/schema_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'schema') 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) + } + } +} -- cgit v1.2.3