Skip to content

Commit

Permalink
fix: fixing name of exclusion option (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
CallumKerson authored Aug 8, 2023
1 parent 458a8e7 commit 234acd1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions cmd/athenaeum/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func runServer(cfg *Config) error {
audiobookOpts = append(audiobookOpts,
audiobooksService.WithThirdPartyNotifier(overcastNotifier.New(cfg.Host, overcastNotifier.WithLogger(logger))))
}
if len(cfg.ExcludsionsFromMainFeed.Genres) > 0 {
genres, err := cfg.ExcludsionsFromMainFeed.GetGenres()
if len(cfg.ExclusionsFromMainFeed.Genres) > 0 {
genres, err := cfg.ExclusionsFromMainFeed.GetGenres()
if err != nil {
return err
}
audiobookOpts = append(audiobookOpts, audiobooksService.WithGenresToExludeFromAllAudiobooks(genres...))
audiobookOpts = append(audiobookOpts, audiobooksService.WithGenresToExcludeFromAllAudiobooks(genres...))
}
audiobookSvc := audiobooksService.New(mediaSvc, boltAudiobookStore, audiobookOpts...)
if errScan := audiobookSvc.UpdateAudiobooks(context.Background()); errScan != nil {
Expand Down
22 changes: 11 additions & 11 deletions cmd/athenaeum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ const (
)

type Config struct {
Host string
Port int
DB DB
Media Media
Podcast Podcast
ThirdParty ThirdParty
Log Log
Cache Cache
ExcludsionsFromMainFeed ExcludsionsFromMainFeed
Host string
Port int
DB DB
Media Media
Podcast Podcast
ThirdParty ThirdParty
Log Log
Cache Cache
ExclusionsFromMainFeed ExclusionsFromMainFeed
}

type Log struct {
Expand Down Expand Up @@ -77,11 +77,11 @@ func (c Cache) GetTTL() time.Duration {
return ttl
}

type ExcludsionsFromMainFeed struct {
type ExclusionsFromMainFeed struct {
Genres []string
}

func (e ExcludsionsFromMainFeed) GetGenres() ([]audiobooks.Genre, error) {
func (e ExclusionsFromMainFeed) GetGenres() ([]audiobooks.Genre, error) {
genres := []audiobooks.Genre{}
for _, genreName := range e.Genres {
genre, err := audiobooks.ParseGenre(genreName)
Expand Down
4 changes: 2 additions & 2 deletions cmd/athenaeum/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestConfig_FromFile(t *testing.T) {
Host: "http://localhost:8088"
Podcast:
Language: FR
ExcludsionsFromMainFeed:
ExclusionsFromMainFeed:
Genres:
- nonfiction
`
Expand All @@ -59,7 +59,7 @@ ExcludsionsFromMainFeed:
assert.Equal(t, "http://localhost:8088", config.Host)
assert.Equal(t, "FR", config.Podcast.Language)

genres, err := config.ExcludsionsFromMainFeed.GetGenres()
genres, err := config.ExclusionsFromMainFeed.GetGenres()
assert.NoError(t, err)
assert.Equal(t, []audiobooks.Genre{audiobooks.NonFiction}, genres)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/audiobooks/service/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func WithThirdPartyNotifier(notifier ThirdPartyNotifier) Option {
}
}

func WithGenresToExludeFromAllAudiobooks(genres ...audiobooks.Genre) Option {
func WithGenresToExcludeFromAllAudiobooks(genres ...audiobooks.Genre) Option {
return func(service *Service) {
if len(genres) > 0 {
var genreFilters []Filter
Expand Down
2 changes: 1 addition & 1 deletion internal/audiobooks/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestFilteringAllAudiobooks(t *testing.T) {
{name: "no filter options", filterOptions: []Option{}, expectedAudiobooks: testbooks.Audiobooks},
{
name: "filter genres from all audibooks",
filterOptions: []Option{WithGenresToExludeFromAllAudiobooks(audiobooks.SciFi)},
filterOptions: []Option{WithGenresToExcludeFromAllAudiobooks(audiobooks.SciFi)},
expectedAudiobooks: []audiobooks.Audiobook{testbooks.Audiobooks[1]},
},
}
Expand Down

0 comments on commit 234acd1

Please sign in to comment.