diff options
| author | siddharth ravikumar <s@ricketyspace.net> | 2026-04-01 20:35:20 -0400 |
|---|---|---|
| committer | siddharth ravikumar <s@ricketyspace.net> | 2026-04-01 20:35:20 -0400 |
| commit | 352d32119b0940d1590cdefef05d44dd75e94342 (patch) | |
| tree | 529e7a0d42b23a4ff1803b83205bd4b8687620a4 /schema | |
| parent | 3387e07ae3900871392424bb82098fa065b97ca9 (diff) | |
schema: add `Entry.DescContains`
Diffstat (limited to 'schema')
| -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) + } + } +} |
