Skip to content

Commit

Permalink
refactor: Move store.FeedParser to internal.FeedParser
Browse files Browse the repository at this point in the history
  • Loading branch information
bow committed Nov 9, 2023
1 parent e323243 commit 74964be
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ lint: ## Lint the code.


.PHONY: mocks
mocks: internal/store/store_mock.go internal/store/parser_mock.go ## Generate mocks from interfaces.
mocks: internal/store/store_mock.go internal/parser_mock.go ## Generate mocks from interfaces.

internal/store/parser_mock.go: internal/store/parser.go
mockgen -source=$< -package=store FeedParser > $@
internal/parser_mock.go: internal/parser.go
mockgen -source=$< -package=internal FeedParser > $@

internal/store/store_mock.go: internal/store/store.go
mockgen -source=$< -self_package=github.com/bow/iris/internal/store -package=store FeedStore > $@
Expand Down
2 changes: 1 addition & 1 deletion internal/store/parser.go → internal/parser.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 Wibowo Arindrarto <[email protected]>
// SPDX-License-Identifier: BSD-3-Clause

package store
package internal

import (
"context"
Expand Down
6 changes: 3 additions & 3 deletions internal/store/parser_mock.go → internal/parser_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type Builder struct {
addr string
store store.FeedStore
storePath string
parser store.FeedParser
parser internal.FeedParser
logger zerolog.Logger
}

Expand Down
2 changes: 1 addition & 1 deletion internal/store/pull_feeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func pullNewFeedEntries(
ctx context.Context,
tx *sql.Tx,
pk pullKey,
parser FeedParser,
parser internal.FeedParser,
) chan internal.PullResult {

pullTime := time.Now().UTC()
Expand Down
4 changes: 2 additions & 2 deletions internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ type FeedStore interface {
type SQLite struct {
db *sql.DB
mu sync.RWMutex
parser FeedParser
parser internal.FeedParser
}

func NewSQLite(filename string) (*SQLite, error) {
return NewSQLiteWithParser(filename, gofeed.NewParser())
}

func NewSQLiteWithParser(filename string, parser FeedParser) (*SQLite, error) {
func NewSQLiteWithParser(filename string, parser internal.FeedParser) (*SQLite, error) {

fail := failF("NewSQLiteStore")

Expand Down
6 changes: 4 additions & 2 deletions internal/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
gomock "github.com/golang/mock/gomock"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"

"github.com/bow/iris/internal"
)

// feedKey is a helper struct for testing.
Expand All @@ -26,7 +28,7 @@ type feedKey struct {
type testStore struct {
*SQLite
t *testing.T
parser *MockFeedParser
parser *internal.MockFeedParser
}

func newTestStore(t *testing.T) testStore {
Expand All @@ -36,7 +38,7 @@ func newTestStore(t *testing.T) testStore {
zerolog.SetGlobalLevel(zerolog.Disabled)

dbPath := filepath.Join(t.TempDir(), t.Name()+".db")
prs := NewMockFeedParser(gomock.NewController(t))
prs := internal.NewMockFeedParser(gomock.NewController(t))
s, err := NewSQLiteWithParser(dbPath, prs)
require.NoError(t, err)

Expand Down

0 comments on commit 74964be

Please sign in to comment.