@@ -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
1420type 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
3238type 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 {
0 commit comments