Skip to content

Commit 2902e89

Browse files
committed
chore: Update common version and add unknown types to logic.
1 parent e6901b6 commit 2902e89

File tree

3 files changed

+173
-2
lines changed

3 files changed

+173
-2
lines changed

internal/apispecdoc/asdRepository.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import (
1010
"gorm.io/gorm/clause"
1111
)
1212

13+
// AsdPage here represents a fixed type.
14+
// It's just overwork for gomock i.e. it can't generate a mock of interface with generics used in it.
15+
// Issue closed https://github.com/golang/mock/issues/621 - awaiting for gomock version 1.7.0.
16+
// TODO delete on gomock 1.7.0 version released
17+
type AsdPage = dto.Page[*ApiSpecDoc]
18+
1319
//go:generate mockgen -source=asdRepository.go -destination=./mocks/asdRepository.go
1420
type AsdRepository interface {
1521
//Save saves new ApiSpecDoc entity to the database
@@ -26,7 +32,7 @@ type AsdRepository interface {
2632
FindByUrl(ctx context.Context, url string) (*ApiSpecDoc, error)
2733
//SearchShort returns a slice of ApiSpecDoc without nested elements that match search string
2834
//The search goes by title and url fields
29-
SearchShort(ctx context.Context, search string, page dto.PageRequest) (dto.Page[*ApiSpecDoc], error)
35+
SearchShort(ctx context.Context, search string, page dto.PageRequest) (AsdPage, error)
3036
}
3137

3238
type AsdRepositoryImpl struct {
@@ -109,7 +115,7 @@ func (r *AsdRepositoryImpl) FindByUrl(ctx context.Context, url string) (*ApiSpec
109115
}
110116
}
111117

112-
func (r *AsdRepositoryImpl) SearchShort(ctx context.Context, search string, page dto.PageRequest) (dto.Page[*ApiSpecDoc], error) {
118+
func (r *AsdRepositoryImpl) SearchShort(ctx context.Context, search string, page dto.PageRequest) (AsdPage, error) {
113119
var specDocs dto.Page[*ApiSpecDoc]
114120
err := r.db.WithContext(ctx).Limit(page.Page).Where("title LIKE ?", "%"+search+"%").Or("url LIKE ?", "%"+search+"%").Find(&specDocs).Error
115121
if err != nil {

internal/apispecdoc/mocks/asdRepository.go

Lines changed: 140 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/apispecdoc/service_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package apispecdoc
2+
3+
import (
4+
"github.com/stretchr/testify/assert"
5+
"testing"
6+
)
7+
8+
func TestServiceImpl_Search(t *testing.T) {
9+
//ctrl := gomock.NewController(t)
10+
//log := mock_logger.NewMockLogger(ctrl)
11+
//repo := mock_api
12+
//service := ServiceImpl{
13+
// log: nil,
14+
// asdRepo: nil,
15+
//}
16+
assert.True(t, false, "implement me please")
17+
}
18+
19+
func TestServiceImpl_Get(t *testing.T) {
20+
assert.True(t, false, "implement me please")
21+
}
22+
23+
func TestServiceImpl_Save(t *testing.T) {
24+
assert.True(t, false, "implement me please")
25+
}

0 commit comments

Comments
 (0)