Decouple config package

This commit is contained in:
Maksym Pavlenko
2022-01-02 14:57:10 +02:00
parent 0edf2836bb
commit 54834550d5
21 changed files with 156 additions and 161 deletions
+2 -2
View File
@@ -3,14 +3,14 @@ package builder
import (
"context"
"github.com/mxpv/podsync/pkg/feed"
"github.com/pkg/errors"
"github.com/mxpv/podsync/pkg/config"
"github.com/mxpv/podsync/pkg/model"
)
type Builder interface {
Build(ctx context.Context, cfg *config.Feed) (*model.Feed, error)
Build(ctx context.Context, cfg *feed.Config) (*model.Feed, error)
}
func New(ctx context.Context, provider model.Provider, key string) (Builder, error) {
+2 -2
View File
@@ -5,10 +5,10 @@ import (
"strconv"
"time"
"github.com/mxpv/podsync/pkg/feed"
"github.com/pkg/errors"
soundcloudapi "github.com/zackradisic/soundcloud-api"
"github.com/mxpv/podsync/pkg/config"
"github.com/mxpv/podsync/pkg/model"
)
@@ -16,7 +16,7 @@ type SoundCloudBuilder struct {
client *soundcloudapi.API
}
func (s *SoundCloudBuilder) Build(_ctx context.Context, cfg *config.Feed) (*model.Feed, error) {
func (s *SoundCloudBuilder) Build(_ctx context.Context, cfg *feed.Config) (*model.Feed, error) {
info, err := ParseURL(cfg.URL)
if err != nil {
return nil, err
+2 -3
View File
@@ -3,10 +3,9 @@ package builder
import (
"testing"
"github.com/mxpv/podsync/pkg/feed"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/mxpv/podsync/pkg/config"
)
func TestSC_BUILDFEED(t *testing.T) {
@@ -20,7 +19,7 @@ func TestSC_BUILDFEED(t *testing.T) {
for _, addr := range urls {
t.Run(addr, func(t *testing.T) {
feed, err := builder.Build(testCtx, &config.Feed{URL: addr})
feed, err := builder.Build(testCtx, &feed.Config{URL: addr})
require.NoError(t, err)
assert.NotEmpty(t, feed.Title)
+2 -2
View File
@@ -6,11 +6,11 @@ import (
"strconv"
"time"
"github.com/mxpv/podsync/pkg/feed"
"github.com/pkg/errors"
"github.com/silentsokolov/go-vimeo/vimeo"
"golang.org/x/oauth2"
"github.com/mxpv/podsync/pkg/config"
"github.com/mxpv/podsync/pkg/model"
)
@@ -158,7 +158,7 @@ func (v *VimeoBuilder) queryVideos(getVideos getVideosFunc, feed *model.Feed) er
}
}
func (v *VimeoBuilder) Build(ctx context.Context, cfg *config.Feed) (*model.Feed, error) {
func (v *VimeoBuilder) Build(ctx context.Context, cfg *feed.Config) (*model.Feed, error) {
info, err := ParseURL(cfg.URL)
if err != nil {
return nil, err
+2 -2
View File
@@ -10,10 +10,10 @@ import (
"time"
"github.com/BrianHicks/finch/duration"
"github.com/mxpv/podsync/pkg/feed"
"github.com/pkg/errors"
"google.golang.org/api/youtube/v3"
"github.com/mxpv/podsync/pkg/config"
"github.com/mxpv/podsync/pkg/model"
)
@@ -384,7 +384,7 @@ func (yt *YouTubeBuilder) queryItems(ctx context.Context, feed *model.Feed) erro
return nil
}
func (yt *YouTubeBuilder) Build(ctx context.Context, cfg *config.Feed) (*model.Feed, error) {
func (yt *YouTubeBuilder) Build(ctx context.Context, cfg *feed.Config) (*model.Feed, error) {
info, err := ParseURL(cfg.URL)
if err != nil {
return nil, err
+2 -2
View File
@@ -5,10 +5,10 @@ import (
"os"
"testing"
"github.com/mxpv/podsync/pkg/feed"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/mxpv/podsync/pkg/config"
"github.com/mxpv/podsync/pkg/model"
)
@@ -53,7 +53,7 @@ func TestYT_BuildFeed(t *testing.T) {
for _, addr := range urls {
t.Run(addr, func(t *testing.T) {
feed, err := builder.Build(testCtx, &config.Feed{URL: addr})
feed, err := builder.Build(testCtx, &feed.Config{URL: addr})
require.NoError(t, err)
assert.NotEmpty(t, feed.Title)