Skip to content

Commit

Permalink
removed mock to avoid increasing complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed Dec 25, 2023
1 parent f1a1305 commit 692b157
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 278 deletions.
1 change: 0 additions & 1 deletion internal/database/database.go
@@ -1,4 +1,3 @@
//go:generate mockgen -destination=../mocks/database.go -package=mocks github.com/go-shiori/shiori/internal/database DB
package database

import (
Expand Down
19 changes: 8 additions & 11 deletions internal/domains/bookmarks_test.go
Expand Up @@ -5,24 +5,25 @@ import (
"testing"

"github.com/go-shiori/shiori/internal/config"
"github.com/go-shiori/shiori/internal/database"
"github.com/go-shiori/shiori/internal/dependencies"
"github.com/go-shiori/shiori/internal/domains"
"github.com/go-shiori/shiori/internal/mocks"
"github.com/go-shiori/shiori/internal/model"
"github.com/go-shiori/shiori/internal/testutil"
"github.com/sirupsen/logrus"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)

func TestBookmarkDomain(t *testing.T) {
fs := afero.NewMemMapFs()

mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
db, err := database.OpenSQLiteDatabase(context.TODO(), ":memory:")
require.NoError(t, err)
require.NoError(t, db.Migrate())

deps := &dependencies.Dependencies{
Database: mocks.NewMockDB(mockCtrl),
Database: db,
Config: config.ParseServerConfiguration(context.TODO(), logrus.New()),
Log: logrus.New(),
Domains: &dependencies.Domains{},
Expand Down Expand Up @@ -67,12 +68,8 @@ func TestBookmarkDomain(t *testing.T) {

t.Run("GetBookmark", func(t *testing.T) {
t.Run("Success", func(t *testing.T) {
deps.Database.(*mocks.MockDB).EXPECT().
GetBookmark(gomock.Any(), 1, "").
Return(model.BookmarkDTO{
ID: 1,
HTML: "<p>hello world</p>",
}, true, nil)
_, err := deps.Database.SaveBookmarks(context.TODO(), true, *testutil.GetValidBookmark())
require.NoError(t, err)
bookmark, err := domain.GetBookmark(context.Background(), 1)
require.NoError(t, err)
require.Equal(t, 1, bookmark.ID)
Expand Down
266 changes: 0 additions & 266 deletions internal/mocks/database.go

This file was deleted.

0 comments on commit 692b157

Please sign in to comment.