@@ -10,6 +10,12 @@ import (
10
10
"gorm.io/gorm/clause"
11
11
)
12
12
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
+
13
19
//go:generate mockgen -source=asdRepository.go -destination=./mocks/asdRepository.go
14
20
type AsdRepository interface {
15
21
//Save saves new ApiSpecDoc entity to the database
@@ -26,7 +32,7 @@ type AsdRepository interface {
26
32
FindByUrl (ctx context.Context , url string ) (* ApiSpecDoc , error )
27
33
//SearchShort returns a slice of ApiSpecDoc without nested elements that match search string
28
34
//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 )
30
36
}
31
37
32
38
type AsdRepositoryImpl struct {
@@ -109,7 +115,7 @@ func (r *AsdRepositoryImpl) FindByUrl(ctx context.Context, url string) (*ApiSpec
109
115
}
110
116
}
111
117
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 ) {
113
119
var specDocs dto.Page [* ApiSpecDoc ]
114
120
err := r .db .WithContext (ctx ).Limit (page .Page ).Where ("title LIKE ?" , "%" + search + "%" ).Or ("url LIKE ?" , "%" + search + "%" ).Find (& specDocs ).Error
115
121
if err != nil {
0 commit comments