Dima 3 mēneši atpakaļ
vecāks
revīzija
1f76b90ab7
47 mainītis faili ar 3175 papildinājumiem un 7846 dzēšanām
  1. 0 40
      .golangci.yml
  2. BIN
      build/app/app
  3. 3 2
      cmd/app/main.go
  4. 4 4
      go.mod
  5. 8 13
      go.sum
  6. 2 2
      internal/dto/article.go
  7. 1 1
      internal/dto/tag.go
  8. 137 34
      internal/fiber/fiber.go
  9. 0 14
      internal/interfaces/auth.go
  10. 0 7
      internal/interfaces/cache.go
  11. 0 37
      internal/interfaces/env.go
  12. 0 5
      internal/interfaces/mailer.go
  13. 0 36
      internal/interfaces/repository.go
  14. 0 12
      internal/interfaces/sp.go
  15. 0 13
      internal/interfaces/user.go
  16. 10 10
      internal/mapper/article.go
  17. 5 9
      internal/mapper/tag.go
  18. 13 17
      internal/repositories/article.go
  19. 6 11
      internal/repositories/article_tag.go
  20. 0 1885
      internal/repositories/mocks/article_repository_minimock.go
  21. 0 742
      internal/repositories/mocks/article_tag_repository_minimock.go
  22. 0 2113
      internal/repositories/mocks/tag_repository_minimock.go
  23. 0 516
      internal/repositories/mocks/user_repository_minimock.go
  24. 14 18
      internal/repositories/tag.go
  25. 8 12
      internal/repositories/user.go
  26. 17 45
      internal/service_provider/sp.go
  27. 23 20
      internal/services/auth/auth.go
  28. 0 969
      internal/services/auth/mocks/auth_minimock.go
  29. 6 12
      internal/services/cache/cache.go
  30. 0 629
      internal/services/cache/mocks/cache_minimock.go
  31. 27 16
      internal/services/db/db.go
  32. 132 89
      internal/services/env/env.go
  33. 97 31
      internal/services/handler/admin/article.go
  34. 18 11
      internal/services/handler/admin/auth.go
  35. 31 20
      internal/services/handler/admin/tag.go
  36. 13 9
      internal/services/handler/admin/user.go
  37. 15 11
      internal/services/handler/article.go
  38. 53 52
      internal/services/handler/article_test.go
  39. 35 7
      internal/services/handler/main_page.go
  40. 23 22
      internal/services/handler/main_page_test.go
  41. 1033 0
      internal/services/handler/mocks/article_repository_minimock.go
  42. 669 0
      internal/services/handler/mocks/cache_service_minimock.go
  43. 700 0
      internal/services/handler/mocks/tag_repository_minimock.go
  44. 12 8
      internal/services/handler/tag.go
  45. 41 40
      internal/services/handler/tag_test.go
  46. 19 18
      internal/services/mailer/mailer.go
  47. 0 284
      internal/services/mailer/mocks/mailer_minimock.go

+ 0 - 40
.golangci.yml

@@ -1,40 +0,0 @@
-# More info on config here: https://golangci-lint.run/usage/configuration/#config-file
-run:
-  skip-dirs:
-    - build
-    - frontend
-    - scripts
-
-output:
-  format: colored-line-number
-  print-issued-lines: true
-  print-linter-name: true
-
-linters-settings:
-  govet:
-    check-shadowing: true
-  revive:
-    min-confidence: 0
-  goconst:
-    min-len:         2
-    min-occurrences: 2
-
-linters:
-  disable-all: true
-  enable:
-    - govet
-    - ineffassign
-    - typecheck
-    - errcheck
-    - goconst
-    - goimports
-    - gosec
-    - revive
-    - gocritic
-    - prealloc
-
-issues:
-  exclude-rules:
-    - linters:
-      - errcheck
-      text: "tx.Rollback"

BIN
build/app/app


+ 3 - 2
cmd/app/main.go

@@ -3,9 +3,10 @@ package main
 import (
 	"log"
 
+	_ "github.com/lib/pq"
+
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/fiber"
 	sp "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/service_provider"
-	_ "github.com/lib/pq"
 )
 
 func main() {
@@ -19,7 +20,7 @@ func main() {
 		log.Fatal(err)
 	}
 
-	if err = fiberApp.Listen(":" + serviceProvider.GetEnvService().GetAppPort()); err != nil {
+	if err = fiberApp.Listen(":" + serviceProvider.EnvService().AppPort()); err != nil {
 		log.Fatal(err)
 	}
 }

+ 4 - 4
go.mod

@@ -1,6 +1,6 @@
 module git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2
 
-go 1.18
+go 1.22.2
 
 require (
 	github.com/Masterminds/squirrel v1.5.3
@@ -11,11 +11,11 @@ require (
 	github.com/gofiber/fiber/v2 v2.42.0
 	github.com/gofiber/jwt/v3 v3.3.6
 	github.com/gofiber/template v1.7.1
-	github.com/gojuno/minimock/v3 v3.0.10
+	github.com/gojuno/minimock/v3 v3.3.13
 	github.com/golang-jwt/jwt/v4 v4.4.3
 	github.com/lib/pq v1.10.7
 	github.com/spf13/viper v1.15.0
-	github.com/stretchr/testify v1.8.1
+	github.com/stretchr/testify v1.8.4
 	golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
 )
 
@@ -49,7 +49,7 @@ require (
 	github.com/valyala/bytebufferpool v1.0.0 // indirect
 	github.com/valyala/fasthttp v1.44.0 // indirect
 	github.com/valyala/tcplisten v1.0.0 // indirect
-	golang.org/x/sys v0.3.0 // indirect
+	golang.org/x/sys v0.5.0 // indirect
 	golang.org/x/text v0.5.0 // indirect
 	gopkg.in/ini.v1 v1.67.0 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect

+ 8 - 13
go.sum

@@ -49,8 +49,6 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
 cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
-git.dmitriygnatenko.ru/dima/homethings v0.0.0-20230210150300-7ce544042cb5 h1:1739BZCRE6hT5XnKz8lSaKrdtwqpmn/ZVGzVAui3ALs=
-git.dmitriygnatenko.ru/dima/homethings v0.0.0-20230210150300-7ce544042cb5/go.mod h1:qxXrmhSuBUJfRukHn2TYE06Rc0adwf7diNfcQUFnUg0=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
 github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
@@ -126,6 +124,7 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL
 github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
 github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8=
 github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
+github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
 github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
 github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
@@ -156,9 +155,8 @@ github.com/gofiber/template v1.7.1 h1:QCRChZA6UrLROgMbzCMKm4a1yqM/5S8RTBKYWZ9GfL
 github.com/gofiber/template v1.7.1/go.mod h1:l3ZOSp8yrMvROzqyh0QTCw7MHet/yLBzaRX+wsiw+gM=
 github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
 github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
-github.com/gojuno/minimock/v3 v3.0.4/go.mod h1:HqeqnwV8mAABn3pO5hqF+RE7gjA0jsN8cbbSogoGrzI=
-github.com/gojuno/minimock/v3 v3.0.10 h1:0UbfgdLHaNRPHWF/RFYPkwxV2KI+SE4tR0dDSFMD7+A=
-github.com/gojuno/minimock/v3 v3.0.10/go.mod h1:CFXcUJYnBe+1QuNzm+WmdPYtvi/+7zQcPcyQGsbcIXg=
+github.com/gojuno/minimock/v3 v3.3.13 h1:sXFO7RbB4JnZiKhgMO4BU4RLYcfhcOSepfiv4wPgGNY=
+github.com/gojuno/minimock/v3 v3.3.13/go.mod h1:WtJbR+15lbzpUHoOFtT7Sv1rR885bFxoyHrzoMOmK/k=
 github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
 github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@@ -208,6 +206,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
+github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
 github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -269,8 +268,6 @@ github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn
 github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
 github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
 github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
-github.com/hexdigest/gowrap v1.1.7/go.mod h1:Z+nBFUDLa01iaNM+/jzoOA1JJ7sm51rnYFauKFUB5fs=
-github.com/hexdigest/gowrap v1.1.8/go.mod h1:H/JiFmQMp//tedlV8qt2xBdGzmne6bpbaSuiHmygnMw=
 github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
@@ -350,7 +347,6 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
 github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
-github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
 github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
 github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
@@ -426,15 +422,15 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
 github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
 github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
 github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
 github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
 github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw=
 github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
-github.com/twitchtv/twirp v5.8.0+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A=
 github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
 github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
 github.com/valyala/fasthttp v1.40.0/go.mod h1:t/G+3rLek+CyY9bnIE+YlMRddxVAAGjhxndDB4i4C0I=
@@ -664,8 +660,8 @@ golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
-golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -692,7 +688,6 @@ golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBn
 golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=

+ 2 - 2
internal/dto/article.go

@@ -1,6 +1,6 @@
 package dto
 
-type ArticleDTO struct {
+type Article struct {
 	ID              int
 	URL             string
 	Title           string
@@ -11,7 +11,7 @@ type ArticleDTO struct {
 	MetaDescription string
 }
 
-type ArticlePreviewDTO struct {
+type ArticlePreview struct {
 	ID          int
 	URL         string
 	Title       string

+ 1 - 1
internal/dto/tag.go

@@ -1,6 +1,6 @@
 package dto
 
-type TagDTO struct {
+type Tag struct {
 	ID  int
 	URL string
 	Tag string

+ 137 - 34
internal/fiber/fiber.go

@@ -6,9 +6,6 @@ import (
 	"strconv"
 	"time"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler"
-	adminHandler "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler/admin"
 	"github.com/gofiber/fiber/v2"
 	"github.com/gofiber/fiber/v2/middleware/basicauth"
 	"github.com/gofiber/fiber/v2/middleware/cors"
@@ -17,6 +14,14 @@ import (
 	"github.com/gofiber/fiber/v2/middleware/recover"
 	jwt "github.com/gofiber/jwt/v3"
 	"github.com/gofiber/template/html"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/repositories"
+	authService "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/auth"
+	cacheService "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/cache"
+	envService "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/env"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler"
+	adminHandler "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler/admin"
+	mailService "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/mailer"
 )
 
 const (
@@ -28,7 +33,25 @@ const (
 	loginRateLimiterExpiration  = 30 * time.Second
 )
 
-func Init(sp interfaces.ServiceProvider) (*fiber.App, error) {
+type (
+	ServiceProvider interface {
+		EnvService() *envService.Service
+		MailerService() *mailService.Service
+		AuthService() *authService.Service
+		CacheService() *cacheService.Service
+		ArticleRepository() *repositories.ArticleRepository
+		TagRepository() *repositories.TagRepository
+		ArticleTagRepository() *repositories.ArticleTagRepository
+		UserRepository() *repositories.UserRepository
+	}
+
+	EnvService interface {
+		StaticVersion() int
+		GAKey() string
+	}
+)
+
+func Init(sp ServiceProvider) (*fiber.App, error) {
 	fiberApp := fiber.New(getConfig(sp))
 
 	// Configure web root
@@ -46,7 +69,7 @@ func Init(sp interfaces.ServiceProvider) (*fiber.App, error) {
 	// Configure Basic auth
 	basicAuth := basicauth.New(basicauth.Config{
 		Users: map[string]string{
-			sp.GetEnvService().GetBasicAuthUser(): sp.GetEnvService().GetBasicAuthPassword(),
+			sp.EnvService().BasicAuthUser(): sp.EnvService().BasicAuthPassword(),
 		},
 	})
 
@@ -54,46 +77,126 @@ func Init(sp interfaces.ServiceProvider) (*fiber.App, error) {
 	fiberApp.Get(metricsURI, basicAuth, monitor.New(getMetricsConfig()))
 
 	// Public handlers
-	fiberApp.Get("/", handler.MainPageHandler(sp))
-	fiberApp.Get("/tag/:tag", handler.TagHandler(sp))
-	fiberApp.Get("/article/:article", handler.ArticleHandler(sp))
+	fiberApp.Get(
+		"/",
+		handler.MainPageHandler(
+			sp.CacheService(),
+			sp.ArticleRepository(),
+		),
+	)
+	fiberApp.Get(
+		"/tag/:tag", handler.TagHandler(
+			sp.CacheService(),
+			sp.ArticleRepository(),
+			sp.TagRepository(),
+		),
+	)
+	fiberApp.Get(
+		"/article/:article",
+		handler.ArticleHandler(
+			sp.CacheService(),
+			sp.ArticleRepository(),
+			sp.TagRepository(),
+		),
+	)
 
 	// Protected handlers
 	admin := fiberApp.Group("/admin", jwtAuth)
-	admin.Get("/", adminHandler.ArticleHandler(sp))
+	admin.Get(
+		"/",
+		adminHandler.ArticleHandler(sp.ArticleRepository()),
+	)
 
 	admin.All("/login", limiter.New(limiter.Config{
 		Max:        loginRateLimiterMaxRequests,
 		Expiration: loginRateLimiterExpiration,
-	}), adminHandler.LoginHandler(sp))
-
-	admin.All("/logout", adminHandler.LogoutHandler(sp))
-	admin.All("/user/change-password", adminHandler.ChangePassword(sp))
-	admin.All("/article/add", adminHandler.AddArticleHandler(sp))
-	admin.All("/article/edit/:id<int>", adminHandler.EditArticleHandler(sp))
-	admin.All("/article/delete/:id<int>", adminHandler.DeleteArticleHandler(sp))
-	admin.Get("/tag", adminHandler.TagHandler(sp))
-	admin.All("/tag/add", adminHandler.AddTagHandler(sp))
-	admin.All("/tag/edit/:id<int>", adminHandler.EditTagHandler(sp))
-	admin.All("/tag/delete/:id<int>", adminHandler.DeleteTagHandler(sp))
+	}), adminHandler.LoginHandler(
+		sp.EnvService(),
+		sp.AuthService(),
+		sp.UserRepository(),
+	))
+
+	admin.All(
+		"/logout",
+		adminHandler.LogoutHandler(sp.EnvService()),
+	)
+
+	admin.All(
+		"/user/change-password",
+		adminHandler.ChangePassword(
+			sp.AuthService(),
+			sp.UserRepository(),
+		),
+	)
+	admin.All(
+		"/article/add",
+		adminHandler.AddArticleHandler(
+			sp.ArticleRepository(),
+			sp.TagRepository(),
+			sp.ArticleTagRepository(),
+			sp.CacheService(),
+		),
+	)
+	admin.All(
+		"/article/edit/:id<int>",
+		adminHandler.EditArticleHandler(
+			sp.ArticleRepository(),
+			sp.TagRepository(),
+			sp.ArticleTagRepository(),
+			sp.CacheService(),
+		),
+	)
+	admin.All(
+		"/article/delete/:id<int>",
+		adminHandler.DeleteArticleHandler(
+			sp.ArticleRepository(),
+			sp.ArticleTagRepository(),
+			sp.CacheService(),
+		),
+	)
+	admin.Get(
+		"/tag",
+		adminHandler.TagHandler(sp.TagRepository()),
+	)
+	admin.All(
+		"/tag/add",
+		adminHandler.AddTagHandler(
+			sp.TagRepository(),
+			sp.CacheService(),
+		),
+	)
+	admin.All(
+		"/tag/edit/:id<int>",
+		adminHandler.EditTagHandler(
+			sp.TagRepository(),
+			sp.CacheService(),
+		),
+	)
+	admin.All(
+		"/tag/delete/:id<int>",
+		adminHandler.DeleteTagHandler(
+			sp.TagRepository(),
+			sp.CacheService(),
+		),
+	)
 
 	return fiberApp, nil
 }
 
-func getConfig(sp interfaces.ServiceProvider) fiber.Config {
+func getConfig(sp ServiceProvider) fiber.Config {
 	return fiber.Config{
 		AppName:               appName,
 		DisableStartupMessage: true,
-		Views:                 getViewsEngine(sp.GetEnvService()),
+		Views:                 getViewsEngine(sp.EnvService()),
 		ErrorHandler:          getErrorHandler(sp),
 	}
 }
 
 // nolint
-func getJWTConfig(sp interfaces.ServiceProvider) jwt.Config {
+func getJWTConfig(sp ServiceProvider) jwt.Config {
 	return jwt.Config{
-		SigningKey:  []byte(sp.GetEnvService().GetJWTSecretKey()),
-		TokenLookup: "cookie:" + sp.GetEnvService().GetJWTCookie(),
+		SigningKey:  []byte(sp.EnvService().JWTSecretKey()),
+		TokenLookup: "cookie:" + sp.EnvService().JWTCookie(),
 		ErrorHandler: func(fctx *fiber.Ctx, err error) error {
 			return fctx.Redirect("/admin/login")
 		},
@@ -121,14 +224,14 @@ func getMetricsConfig() monitor.Config {
 	}
 }
 
-func getCORSConfig(sp interfaces.ServiceProvider) cors.Config {
+func getCORSConfig(sp ServiceProvider) cors.Config {
 	return cors.Config{
-		AllowOrigins: sp.GetEnvService().GetCORSAllowOrigins(),
-		AllowMethods: sp.GetEnvService().GetCORSAllowMethods(),
+		AllowOrigins: sp.EnvService().CORSAllowOrigins(),
+		AllowMethods: sp.EnvService().CORSAllowMethods(),
 	}
 }
 
-func getViewsEngine(env interfaces.Env) *html.Engine {
+func getViewsEngine(env EnvService) *html.Engine {
 	engine := html.New(templatesPath, ".html")
 
 	// nolint:gocritic
@@ -147,17 +250,17 @@ func getViewsEngine(env interfaces.Env) *html.Engine {
 	})
 
 	engine.AddFunc("version", func() string {
-		return strconv.Itoa(env.GetStaticVersion())
+		return strconv.Itoa(env.StaticVersion())
 	})
 
 	engine.AddFunc("ga", func() string {
-		return env.GetGAKey()
+		return env.GAKey()
 	})
 
 	return engine
 }
 
-func getErrorHandler(sp interfaces.ServiceProvider) fiber.ErrorHandler {
+func getErrorHandler(sp ServiceProvider) fiber.ErrorHandler {
 	return func(fctx *fiber.Ctx, err error) error {
 		errCode := fiber.StatusInternalServerError
 		if e, ok := err.(*fiber.Error); ok {
@@ -165,11 +268,11 @@ func getErrorHandler(sp interfaces.ServiceProvider) fiber.ErrorHandler {
 		}
 
 		if err.Error() != "" {
-			errorsEmail := sp.GetEnvService().GetErrorsEmail()
+			errorsEmail := sp.EnvService().ErrorsEmail()
 			if errCode == fiber.StatusInternalServerError && errorsEmail != "" {
 				log.Println(err)
 				// nolint
-				sp.GetMailerService().Send(
+				sp.MailerService().Send(
 					errorsEmail,
 					"AUTO - dmitriygnatenko.ru error",
 					err.Error(),

+ 0 - 14
internal/interfaces/auth.go

@@ -1,14 +0,0 @@
-package interfaces
-
-import (
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	"github.com/gofiber/fiber/v2"
-	"github.com/golang-jwt/jwt/v4"
-)
-
-type Auth interface {
-	GeneratePasswordHash(password string) (string, error)
-	IsCorrectPassword(password string, hash string) bool
-	GenerateToken(user models.User) (string, error)
-	GetClaims(fctx *fiber.Ctx) jwt.MapClaims
-}

+ 0 - 7
internal/interfaces/cache.go

@@ -1,7 +0,0 @@
-package interfaces
-
-type Cache interface {
-	Get(key string) (interface{}, bool)
-	Set(key string, value interface{})
-	FlushAll()
-}

+ 0 - 37
internal/interfaces/env.go

@@ -1,37 +0,0 @@
-package interfaces
-
-type Env interface {
-	GetAppPort() string
-
-	GetDBHost() string
-	GetDBPort() string
-	GetDBName() string
-	GetDBUser() string
-	GetDBPassword() string
-
-	GetDBMaxOpenConns() int
-	GetDBMaxIdleConns() int
-	GetDBMaxConnLifetime() int
-	GetDBMaxIdleConnLifetime() int
-
-	GetCORSAllowOrigins() string
-	GetCORSAllowMethods() string
-
-	GetSMTPHost() string
-	GetSMTPPort() string
-	GetSMTPUser() string
-	GetSMTPPassword() string
-
-	GetJWTSecretKey() string
-	GetJWTCookie() string
-	GetJWTLifetime() int
-
-	GetBasicAuthUser() string
-	GetBasicAuthPassword() string
-
-	GetErrorsEmail() string
-
-	GetStaticVersion() int
-
-	GetGAKey() string
-}

+ 0 - 5
internal/interfaces/mailer.go

@@ -1,5 +0,0 @@
-package interfaces
-
-type Mailer interface {
-	Send(recipient string, subject string, text string) error
-}

+ 0 - 36
internal/interfaces/repository.go

@@ -1,36 +0,0 @@
-package interfaces
-
-import (
-	"context"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-)
-
-type ArticleRepository interface {
-	GetAll(ctx context.Context) ([]models.Article, error)
-	GetAllPreview(ctx context.Context) ([]models.ArticlePreview, error)
-	GetPreviewByTagID(ctx context.Context, tagID int) ([]models.ArticlePreview, error)
-	GetByURL(ctx context.Context, url string) (*models.Article, error)
-	GetByID(ctx context.Context, ID int) (*models.Article, error)
-	Add(ctx context.Context, m models.Article) (int, error)
-	Update(ctx context.Context, m models.Article) error
-	Delete(ctx context.Context, ID int) error
-}
-
-type TagRepository interface {
-	GetAll(ctx context.Context) ([]models.Tag, error)
-	GetAllUsed(ctx context.Context) ([]models.Tag, error)
-	IsUsed(ctx context.Context, ID int) (bool, error)
-	GetByArticleID(ctx context.Context, ID int) ([]models.Tag, error)
-	GetByURL(ctx context.Context, tag string) (*models.Tag, error)
-	GetByID(ctx context.Context, ID int) (*models.Tag, error)
-	Add(ctx context.Context, m models.Tag) error
-	Update(ctx context.Context, m models.Tag) error
-	Delete(ctx context.Context, ID int) error
-}
-
-type ArticleTagRepository interface {
-	Add(ctx context.Context, articleID int, tagIDs []int) error
-	Delete(ctx context.Context, articleID int, tagIDs []int) error
-	DeleteByArticleID(ctx context.Context, articleID int) error
-}

+ 0 - 12
internal/interfaces/sp.go

@@ -1,12 +0,0 @@
-package interfaces
-
-type ServiceProvider interface {
-	GetEnvService() Env
-	GetCacheService() Cache
-	GetMailerService() Mailer
-	GetAuthService() Auth
-	GetArticleRepository() ArticleRepository
-	GetTagRepository() TagRepository
-	GetArticleTagRepository() ArticleTagRepository
-	GetUserRepository() UserRepository
-}

+ 0 - 13
internal/interfaces/user.go

@@ -1,13 +0,0 @@
-package interfaces
-
-import (
-	"context"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-)
-
-type UserRepository interface {
-	Get(ctx context.Context, username string) (*models.User, error)
-	Add(ctx context.Context, username string, password string) (int, error)
-	UpdatePassword(ctx context.Context, id int, newPassword string) error
-}

+ 10 - 10
internal/mapper/article.go

@@ -8,11 +8,11 @@ import (
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 )
 
-func ConvertArticleModelsToDTO(m []models.Article) []dto.ArticleDTO {
-	res := make([]dto.ArticleDTO, 0, len(m))
+func ToArticleDTOList(m []models.Article) []dto.Article {
+	res := make([]dto.Article, 0, len(m))
 
 	for i := range m {
-		res = append(res, dto.ArticleDTO{
+		res = append(res, dto.Article{
 			ID:              m[i].ID,
 			URL:             m[i].URL,
 			Title:           m[i].Title,
@@ -27,8 +27,8 @@ func ConvertArticleModelsToDTO(m []models.Article) []dto.ArticleDTO {
 	return res
 }
 
-func ConvertArticleModelToDTO(m models.Article) *dto.ArticleDTO {
-	return &dto.ArticleDTO{
+func ToArticleDTO(m models.Article) *dto.Article {
+	return &dto.Article{
 		ID:              m.ID,
 		URL:             m.URL,
 		Title:           m.Title,
@@ -40,11 +40,11 @@ func ConvertArticleModelToDTO(m models.Article) *dto.ArticleDTO {
 	}
 }
 
-func ConvertArticlePreviewModelsToDTO(m []models.ArticlePreview) []dto.ArticlePreviewDTO {
-	res := make([]dto.ArticlePreviewDTO, 0, len(m))
+func ToArticlePreviewDTOList(m []models.ArticlePreview) []dto.ArticlePreview {
+	res := make([]dto.ArticlePreview, 0, len(m))
 
 	for i := range m {
-		res = append(res, dto.ArticlePreviewDTO{
+		res = append(res, dto.ArticlePreview{
 			ID:          m[i].ID,
 			URL:         m[i].URL,
 			Title:       m[i].Title,
@@ -57,7 +57,7 @@ func ConvertArticlePreviewModelsToDTO(m []models.ArticlePreview) []dto.ArticlePr
 	return res
 }
 
-func ConvertArticleModelToForm(a models.Article, tags []models.Tag) *models.ArticleForm {
+func ToArticleForm(a models.Article, tags []models.Tag) *models.ArticleForm {
 	tagMap := make(map[int]bool, len(tags))
 	for i := range tags {
 		tagMap[tags[i].ID] = true
@@ -78,7 +78,7 @@ func ConvertArticleModelToForm(a models.Article, tags []models.Tag) *models.Arti
 	}
 }
 
-func ConvertArticleFormToModel(f models.ArticleForm) (*models.Article, error) {
+func ToArticle(f models.ArticleForm) (*models.Article, error) {
 	var previewText, image, metaKeywords, metaDesc sql.NullString
 
 	if f.PreviewText != "" {

+ 5 - 9
internal/mapper/tag.go

@@ -5,11 +5,11 @@ import (
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 )
 
-func ConvertTagModelsToDTO(m []models.Tag) []dto.TagDTO {
-	res := make([]dto.TagDTO, 0, len(m))
+func ToTagDTOList(m []models.Tag) []dto.Tag {
+	res := make([]dto.Tag, 0, len(m))
 
 	for i := range m {
-		res = append(res, dto.TagDTO{
+		res = append(res, dto.Tag{
 			ID:  m[i].ID,
 			URL: m[i].URL,
 			Tag: m[i].Tag,
@@ -19,10 +19,6 @@ func ConvertTagModelsToDTO(m []models.Tag) []dto.TagDTO {
 	return res
 }
 
-func ConvertTagFormToModel(form models.TagForm) models.Tag {
-	return models.Tag{
-		ID:  form.ID,
-		Tag: form.Tag,
-		URL: form.URL,
-	}
+func ToTag(form models.TagForm) models.Tag {
+	return models.Tag(form)
 }

+ 13 - 17
internal/repositories/article.go

@@ -1,29 +1,25 @@
 package repositories
 
-//go:generate mkdir -p mocks
-//go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.ArticleRepository -o ./mocks/ -s "_minimock.go"
-
 import (
 	"context"
 	"database/sql"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 	sq "github.com/Masterminds/squirrel"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 )
 
 const articleTableName = "article"
 
-type articleRepository struct {
+type ArticleRepository struct {
 	db *sql.DB
 }
 
-func InitArticleRepository(db *sql.DB) interfaces.ArticleRepository {
-	return articleRepository{db: db}
+func InitArticleRepository(db *sql.DB) *ArticleRepository {
+	return &ArticleRepository{db: db}
 }
 
-func (a articleRepository) GetAllPreview(ctx context.Context) ([]models.ArticlePreview, error) {
+func (a ArticleRepository) GetAllPreview(ctx context.Context) ([]models.ArticlePreview, error) {
 	var res []models.ArticlePreview
 
 	query, args, err := sq.Select("id", "url", "publish_time", "title", "preview_text", "image").
@@ -61,7 +57,7 @@ func (a articleRepository) GetAllPreview(ctx context.Context) ([]models.ArticleP
 	return res, nil
 }
 
-func (a articleRepository) GetAll(ctx context.Context) ([]models.Article, error) {
+func (a ArticleRepository) GetAll(ctx context.Context) ([]models.Article, error) {
 	var res []models.Article
 
 	// nolint
@@ -94,7 +90,7 @@ func (a articleRepository) GetAll(ctx context.Context) ([]models.Article, error)
 	return res, nil
 }
 
-func (a articleRepository) GetPreviewByTagID(ctx context.Context, tagID int) ([]models.ArticlePreview, error) {
+func (a ArticleRepository) GetPreviewByTagID(ctx context.Context, tagID int) ([]models.ArticlePreview, error) {
 	var res []models.ArticlePreview
 
 	query := "SELECT a.id, a.url, a.publish_time, a.title, a.preview_text, a.image " +
@@ -126,7 +122,7 @@ func (a articleRepository) GetPreviewByTagID(ctx context.Context, tagID int) ([]
 	return res, nil
 }
 
-func (a articleRepository) GetByURL(ctx context.Context, url string) (*models.Article, error) {
+func (a ArticleRepository) GetByURL(ctx context.Context, url string) (*models.Article, error) {
 	var res models.Article
 
 	query, args, err := sq.Select("id", "url", "publish_time", "title", "image", "text", "preview_text", "meta_keywords", "meta_desc", "is_active").
@@ -150,7 +146,7 @@ func (a articleRepository) GetByURL(ctx context.Context, url string) (*models.Ar
 	return &res, nil
 }
 
-func (a articleRepository) GetByID(ctx context.Context, id int) (*models.Article, error) {
+func (a ArticleRepository) GetByID(ctx context.Context, id int) (*models.Article, error) {
 	var res models.Article
 
 	query, args, err := sq.Select("id", "url", "publish_time", "title", "image", "text", "preview_text", "meta_keywords", "meta_desc", "is_active").
@@ -174,7 +170,7 @@ func (a articleRepository) GetByID(ctx context.Context, id int) (*models.Article
 	return &res, nil
 }
 
-func (a articleRepository) Add(ctx context.Context, m models.Article) (int, error) {
+func (a ArticleRepository) Add(ctx context.Context, m models.Article) (int, error) {
 	query, args, err := sq.Insert(articleTableName).
 		PlaceholderFormat(sq.Dollar).
 		Columns("url", "publish_time", "title", "image", "text", "preview_text", "meta_keywords", "meta_desc", "is_active").
@@ -195,7 +191,7 @@ func (a articleRepository) Add(ctx context.Context, m models.Article) (int, erro
 	return id, nil
 }
 
-func (a articleRepository) Update(ctx context.Context, req models.Article) error {
+func (a ArticleRepository) Update(ctx context.Context, req models.Article) error {
 	query, args, err := sq.Update(articleTableName).
 		PlaceholderFormat(sq.Dollar).
 		Set("url", req.URL).
@@ -219,7 +215,7 @@ func (a articleRepository) Update(ctx context.Context, req models.Article) error
 	return err
 }
 
-func (a articleRepository) Delete(ctx context.Context, id int) error {
+func (a ArticleRepository) Delete(ctx context.Context, id int) error {
 	query, args, err := sq.Delete(articleTableName).
 		PlaceholderFormat(sq.Dollar).
 		Where(sq.Eq{"id": id}).

+ 6 - 11
internal/repositories/article_tag.go

@@ -1,28 +1,23 @@
 package repositories
 
-//go:generate mkdir -p mocks
-//go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.ArticleTagRepository -o ./mocks/ -s "_minimock.go"
-
 import (
 	"context"
 	"database/sql"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
 	sq "github.com/Masterminds/squirrel"
 )
 
 const articleTagTableName = "article_tag"
 
-type articleTagRepository struct {
+type ArticleTagRepository struct {
 	db *sql.DB
 }
 
-func InitArticleTagRepository(db *sql.DB) interfaces.ArticleTagRepository {
-	return articleTagRepository{db: db}
+func InitArticleTagRepository(db *sql.DB) *ArticleTagRepository {
+	return &ArticleTagRepository{db: db}
 }
 
-func (a articleTagRepository) Add(ctx context.Context, articleID int, tagIDs []int) error {
+func (a ArticleTagRepository) Add(ctx context.Context, articleID int, tagIDs []int) error {
 	if len(tagIDs) == 0 {
 		return nil
 	}
@@ -45,7 +40,7 @@ func (a articleTagRepository) Add(ctx context.Context, articleID int, tagIDs []i
 	return err
 }
 
-func (a articleTagRepository) Delete(ctx context.Context, articleID int, tagIDs []int) error {
+func (a ArticleTagRepository) Delete(ctx context.Context, articleID int, tagIDs []int) error {
 	if len(tagIDs) == 0 {
 		return nil
 	}
@@ -65,7 +60,7 @@ func (a articleTagRepository) Delete(ctx context.Context, articleID int, tagIDs
 	return err
 }
 
-func (a articleTagRepository) DeleteByArticleID(ctx context.Context, articleID int) error {
+func (a ArticleTagRepository) DeleteByArticleID(ctx context.Context, articleID int) error {
 	query, args, err := sq.Delete(articleTagTableName).
 		PlaceholderFormat(sq.Dollar).
 		Where(sq.Eq{"article_id": articleID}).

+ 0 - 1885
internal/repositories/mocks/article_repository_minimock.go

@@ -1,1885 +0,0 @@
-package mocks
-
-// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
-
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.ArticleRepository -o ./mocks/article_repository_minimock.go -n ArticleRepositoryMock
-
-import (
-	"context"
-	"sync"
-	mm_atomic "sync/atomic"
-	mm_time "time"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	"github.com/gojuno/minimock/v3"
-)
-
-// ArticleRepositoryMock implements interfaces.ArticleRepository
-type ArticleRepositoryMock struct {
-	t minimock.Tester
-
-	funcAdd          func(ctx context.Context, m models.Article) (i1 int, err error)
-	inspectFuncAdd   func(ctx context.Context, m models.Article)
-	afterAddCounter  uint64
-	beforeAddCounter uint64
-	AddMock          mArticleRepositoryMockAdd
-
-	funcDelete          func(ctx context.Context, ID int) (err error)
-	inspectFuncDelete   func(ctx context.Context, ID int)
-	afterDeleteCounter  uint64
-	beforeDeleteCounter uint64
-	DeleteMock          mArticleRepositoryMockDelete
-
-	funcGetAll          func(ctx context.Context) (aa1 []models.Article, err error)
-	inspectFuncGetAll   func(ctx context.Context)
-	afterGetAllCounter  uint64
-	beforeGetAllCounter uint64
-	GetAllMock          mArticleRepositoryMockGetAll
-
-	funcGetAllPreview          func(ctx context.Context) (aa1 []models.ArticlePreview, err error)
-	inspectFuncGetAllPreview   func(ctx context.Context)
-	afterGetAllPreviewCounter  uint64
-	beforeGetAllPreviewCounter uint64
-	GetAllPreviewMock          mArticleRepositoryMockGetAllPreview
-
-	funcGetByID          func(ctx context.Context, ID int) (ap1 *models.Article, err error)
-	inspectFuncGetByID   func(ctx context.Context, ID int)
-	afterGetByIDCounter  uint64
-	beforeGetByIDCounter uint64
-	GetByIDMock          mArticleRepositoryMockGetByID
-
-	funcGetByURL          func(ctx context.Context, url string) (ap1 *models.Article, err error)
-	inspectFuncGetByURL   func(ctx context.Context, url string)
-	afterGetByURLCounter  uint64
-	beforeGetByURLCounter uint64
-	GetByURLMock          mArticleRepositoryMockGetByURL
-
-	funcGetPreviewByTagID          func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error)
-	inspectFuncGetPreviewByTagID   func(ctx context.Context, tagID int)
-	afterGetPreviewByTagIDCounter  uint64
-	beforeGetPreviewByTagIDCounter uint64
-	GetPreviewByTagIDMock          mArticleRepositoryMockGetPreviewByTagID
-
-	funcUpdate          func(ctx context.Context, m models.Article) (err error)
-	inspectFuncUpdate   func(ctx context.Context, m models.Article)
-	afterUpdateCounter  uint64
-	beforeUpdateCounter uint64
-	UpdateMock          mArticleRepositoryMockUpdate
-}
-
-// NewArticleRepositoryMock returns a mock for interfaces.ArticleRepository
-func NewArticleRepositoryMock(t minimock.Tester) *ArticleRepositoryMock {
-	m := &ArticleRepositoryMock{t: t}
-	if controller, ok := t.(minimock.MockController); ok {
-		controller.RegisterMocker(m)
-	}
-
-	m.AddMock = mArticleRepositoryMockAdd{mock: m}
-	m.AddMock.callArgs = []*ArticleRepositoryMockAddParams{}
-
-	m.DeleteMock = mArticleRepositoryMockDelete{mock: m}
-	m.DeleteMock.callArgs = []*ArticleRepositoryMockDeleteParams{}
-
-	m.GetAllMock = mArticleRepositoryMockGetAll{mock: m}
-	m.GetAllMock.callArgs = []*ArticleRepositoryMockGetAllParams{}
-
-	m.GetAllPreviewMock = mArticleRepositoryMockGetAllPreview{mock: m}
-	m.GetAllPreviewMock.callArgs = []*ArticleRepositoryMockGetAllPreviewParams{}
-
-	m.GetByIDMock = mArticleRepositoryMockGetByID{mock: m}
-	m.GetByIDMock.callArgs = []*ArticleRepositoryMockGetByIDParams{}
-
-	m.GetByURLMock = mArticleRepositoryMockGetByURL{mock: m}
-	m.GetByURLMock.callArgs = []*ArticleRepositoryMockGetByURLParams{}
-
-	m.GetPreviewByTagIDMock = mArticleRepositoryMockGetPreviewByTagID{mock: m}
-	m.GetPreviewByTagIDMock.callArgs = []*ArticleRepositoryMockGetPreviewByTagIDParams{}
-
-	m.UpdateMock = mArticleRepositoryMockUpdate{mock: m}
-	m.UpdateMock.callArgs = []*ArticleRepositoryMockUpdateParams{}
-
-	return m
-}
-
-type mArticleRepositoryMockAdd struct {
-	mock               *ArticleRepositoryMock
-	defaultExpectation *ArticleRepositoryMockAddExpectation
-	expectations       []*ArticleRepositoryMockAddExpectation
-
-	callArgs []*ArticleRepositoryMockAddParams
-	mutex    sync.RWMutex
-}
-
-// ArticleRepositoryMockAddExpectation specifies expectation struct of the ArticleRepository.Add
-type ArticleRepositoryMockAddExpectation struct {
-	mock    *ArticleRepositoryMock
-	params  *ArticleRepositoryMockAddParams
-	results *ArticleRepositoryMockAddResults
-	Counter uint64
-}
-
-// ArticleRepositoryMockAddParams contains parameters of the ArticleRepository.Add
-type ArticleRepositoryMockAddParams struct {
-	ctx context.Context
-	m   models.Article
-}
-
-// ArticleRepositoryMockAddResults contains results of the ArticleRepository.Add
-type ArticleRepositoryMockAddResults struct {
-	i1  int
-	err error
-}
-
-// Expect sets up expected params for ArticleRepository.Add
-func (mmAdd *mArticleRepositoryMockAdd) Expect(ctx context.Context, m models.Article) *mArticleRepositoryMockAdd {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("ArticleRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &ArticleRepositoryMockAddExpectation{}
-	}
-
-	mmAdd.defaultExpectation.params = &ArticleRepositoryMockAddParams{ctx, m}
-	for _, e := range mmAdd.expectations {
-		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
-			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
-		}
-	}
-
-	return mmAdd
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleRepository.Add
-func (mmAdd *mArticleRepositoryMockAdd) Inspect(f func(ctx context.Context, m models.Article)) *mArticleRepositoryMockAdd {
-	if mmAdd.mock.inspectFuncAdd != nil {
-		mmAdd.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.Add")
-	}
-
-	mmAdd.mock.inspectFuncAdd = f
-
-	return mmAdd
-}
-
-// Return sets up results that will be returned by ArticleRepository.Add
-func (mmAdd *mArticleRepositoryMockAdd) Return(i1 int, err error) *ArticleRepositoryMock {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("ArticleRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &ArticleRepositoryMockAddExpectation{mock: mmAdd.mock}
-	}
-	mmAdd.defaultExpectation.results = &ArticleRepositoryMockAddResults{i1, err}
-	return mmAdd.mock
-}
-
-// Set uses given function f to mock the ArticleRepository.Add method
-func (mmAdd *mArticleRepositoryMockAdd) Set(f func(ctx context.Context, m models.Article) (i1 int, err error)) *ArticleRepositoryMock {
-	if mmAdd.defaultExpectation != nil {
-		mmAdd.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.Add method")
-	}
-
-	if len(mmAdd.expectations) > 0 {
-		mmAdd.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.Add method")
-	}
-
-	mmAdd.mock.funcAdd = f
-	return mmAdd.mock
-}
-
-// When sets expectation for the ArticleRepository.Add which will trigger the result defined by the following
-// Then helper
-func (mmAdd *mArticleRepositoryMockAdd) When(ctx context.Context, m models.Article) *ArticleRepositoryMockAddExpectation {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("ArticleRepositoryMock.Add mock is already set by Set")
-	}
-
-	expectation := &ArticleRepositoryMockAddExpectation{
-		mock:   mmAdd.mock,
-		params: &ArticleRepositoryMockAddParams{ctx, m},
-	}
-	mmAdd.expectations = append(mmAdd.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleRepository.Add return parameters for the expectation previously defined by the When method
-func (e *ArticleRepositoryMockAddExpectation) Then(i1 int, err error) *ArticleRepositoryMock {
-	e.results = &ArticleRepositoryMockAddResults{i1, err}
-	return e.mock
-}
-
-// Add implements interfaces.ArticleRepository
-func (mmAdd *ArticleRepositoryMock) Add(ctx context.Context, m models.Article) (i1 int, err error) {
-	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
-	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
-
-	if mmAdd.inspectFuncAdd != nil {
-		mmAdd.inspectFuncAdd(ctx, m)
-	}
-
-	mm_params := &ArticleRepositoryMockAddParams{ctx, m}
-
-	// Record call args
-	mmAdd.AddMock.mutex.Lock()
-	mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params)
-	mmAdd.AddMock.mutex.Unlock()
-
-	for _, e := range mmAdd.AddMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.i1, e.results.err
-		}
-	}
-
-	if mmAdd.AddMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
-		mm_want := mmAdd.AddMock.defaultExpectation.params
-		mm_got := ArticleRepositoryMockAddParams{ctx, m}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmAdd.t.Errorf("ArticleRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmAdd.AddMock.defaultExpectation.results
-		if mm_results == nil {
-			mmAdd.t.Fatal("No results are set for the ArticleRepositoryMock.Add")
-		}
-		return (*mm_results).i1, (*mm_results).err
-	}
-	if mmAdd.funcAdd != nil {
-		return mmAdd.funcAdd(ctx, m)
-	}
-	mmAdd.t.Fatalf("Unexpected call to ArticleRepositoryMock.Add. %v %v", ctx, m)
-	return
-}
-
-// AddAfterCounter returns a count of finished ArticleRepositoryMock.Add invocations
-func (mmAdd *ArticleRepositoryMock) AddAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
-}
-
-// AddBeforeCounter returns a count of ArticleRepositoryMock.Add invocations
-func (mmAdd *ArticleRepositoryMock) AddBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleRepositoryMock.Add.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmAdd *mArticleRepositoryMockAdd) Calls() []*ArticleRepositoryMockAddParams {
-	mmAdd.mutex.RLock()
-
-	argCopy := make([]*ArticleRepositoryMockAddParams, len(mmAdd.callArgs))
-	copy(argCopy, mmAdd.callArgs)
-
-	mmAdd.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockAddDone returns true if the count of the Add invocations corresponds
-// the number of defined expectations
-func (m *ArticleRepositoryMock) MinimockAddDone() bool {
-	for _, e := range m.AddMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockAddInspect logs each unmet expectation
-func (m *ArticleRepositoryMock) MinimockAddInspect() {
-	for _, e := range m.AddMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.Add with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		if m.AddMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleRepositoryMock.Add")
-		} else {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		m.t.Error("Expected call to ArticleRepositoryMock.Add")
-	}
-}
-
-type mArticleRepositoryMockDelete struct {
-	mock               *ArticleRepositoryMock
-	defaultExpectation *ArticleRepositoryMockDeleteExpectation
-	expectations       []*ArticleRepositoryMockDeleteExpectation
-
-	callArgs []*ArticleRepositoryMockDeleteParams
-	mutex    sync.RWMutex
-}
-
-// ArticleRepositoryMockDeleteExpectation specifies expectation struct of the ArticleRepository.Delete
-type ArticleRepositoryMockDeleteExpectation struct {
-	mock    *ArticleRepositoryMock
-	params  *ArticleRepositoryMockDeleteParams
-	results *ArticleRepositoryMockDeleteResults
-	Counter uint64
-}
-
-// ArticleRepositoryMockDeleteParams contains parameters of the ArticleRepository.Delete
-type ArticleRepositoryMockDeleteParams struct {
-	ctx context.Context
-	ID  int
-}
-
-// ArticleRepositoryMockDeleteResults contains results of the ArticleRepository.Delete
-type ArticleRepositoryMockDeleteResults struct {
-	err error
-}
-
-// Expect sets up expected params for ArticleRepository.Delete
-func (mmDelete *mArticleRepositoryMockDelete) Expect(ctx context.Context, ID int) *mArticleRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ArticleRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ArticleRepositoryMockDeleteExpectation{}
-	}
-
-	mmDelete.defaultExpectation.params = &ArticleRepositoryMockDeleteParams{ctx, ID}
-	for _, e := range mmDelete.expectations {
-		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
-			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
-		}
-	}
-
-	return mmDelete
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleRepository.Delete
-func (mmDelete *mArticleRepositoryMockDelete) Inspect(f func(ctx context.Context, ID int)) *mArticleRepositoryMockDelete {
-	if mmDelete.mock.inspectFuncDelete != nil {
-		mmDelete.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.Delete")
-	}
-
-	mmDelete.mock.inspectFuncDelete = f
-
-	return mmDelete
-}
-
-// Return sets up results that will be returned by ArticleRepository.Delete
-func (mmDelete *mArticleRepositoryMockDelete) Return(err error) *ArticleRepositoryMock {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ArticleRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ArticleRepositoryMockDeleteExpectation{mock: mmDelete.mock}
-	}
-	mmDelete.defaultExpectation.results = &ArticleRepositoryMockDeleteResults{err}
-	return mmDelete.mock
-}
-
-// Set uses given function f to mock the ArticleRepository.Delete method
-func (mmDelete *mArticleRepositoryMockDelete) Set(f func(ctx context.Context, ID int) (err error)) *ArticleRepositoryMock {
-	if mmDelete.defaultExpectation != nil {
-		mmDelete.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.Delete method")
-	}
-
-	if len(mmDelete.expectations) > 0 {
-		mmDelete.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.Delete method")
-	}
-
-	mmDelete.mock.funcDelete = f
-	return mmDelete.mock
-}
-
-// When sets expectation for the ArticleRepository.Delete which will trigger the result defined by the following
-// Then helper
-func (mmDelete *mArticleRepositoryMockDelete) When(ctx context.Context, ID int) *ArticleRepositoryMockDeleteExpectation {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ArticleRepositoryMock.Delete mock is already set by Set")
-	}
-
-	expectation := &ArticleRepositoryMockDeleteExpectation{
-		mock:   mmDelete.mock,
-		params: &ArticleRepositoryMockDeleteParams{ctx, ID},
-	}
-	mmDelete.expectations = append(mmDelete.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleRepository.Delete return parameters for the expectation previously defined by the When method
-func (e *ArticleRepositoryMockDeleteExpectation) Then(err error) *ArticleRepositoryMock {
-	e.results = &ArticleRepositoryMockDeleteResults{err}
-	return e.mock
-}
-
-// Delete implements interfaces.ArticleRepository
-func (mmDelete *ArticleRepositoryMock) Delete(ctx context.Context, ID int) (err error) {
-	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
-	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
-
-	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, ID)
-	}
-
-	mm_params := &ArticleRepositoryMockDeleteParams{ctx, ID}
-
-	// Record call args
-	mmDelete.DeleteMock.mutex.Lock()
-	mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, mm_params)
-	mmDelete.DeleteMock.mutex.Unlock()
-
-	for _, e := range mmDelete.DeleteMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmDelete.DeleteMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
-		mm_want := mmDelete.DeleteMock.defaultExpectation.params
-		mm_got := ArticleRepositoryMockDeleteParams{ctx, ID}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmDelete.t.Errorf("ArticleRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmDelete.DeleteMock.defaultExpectation.results
-		if mm_results == nil {
-			mmDelete.t.Fatal("No results are set for the ArticleRepositoryMock.Delete")
-		}
-		return (*mm_results).err
-	}
-	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, ID)
-	}
-	mmDelete.t.Fatalf("Unexpected call to ArticleRepositoryMock.Delete. %v %v", ctx, ID)
-	return
-}
-
-// DeleteAfterCounter returns a count of finished ArticleRepositoryMock.Delete invocations
-func (mmDelete *ArticleRepositoryMock) DeleteAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
-}
-
-// DeleteBeforeCounter returns a count of ArticleRepositoryMock.Delete invocations
-func (mmDelete *ArticleRepositoryMock) DeleteBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleRepositoryMock.Delete.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmDelete *mArticleRepositoryMockDelete) Calls() []*ArticleRepositoryMockDeleteParams {
-	mmDelete.mutex.RLock()
-
-	argCopy := make([]*ArticleRepositoryMockDeleteParams, len(mmDelete.callArgs))
-	copy(argCopy, mmDelete.callArgs)
-
-	mmDelete.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockDeleteDone returns true if the count of the Delete invocations corresponds
-// the number of defined expectations
-func (m *ArticleRepositoryMock) MinimockDeleteDone() bool {
-	for _, e := range m.DeleteMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockDeleteInspect logs each unmet expectation
-func (m *ArticleRepositoryMock) MinimockDeleteInspect() {
-	for _, e := range m.DeleteMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.Delete with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		if m.DeleteMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleRepositoryMock.Delete")
-		} else {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		m.t.Error("Expected call to ArticleRepositoryMock.Delete")
-	}
-}
-
-type mArticleRepositoryMockGetAll struct {
-	mock               *ArticleRepositoryMock
-	defaultExpectation *ArticleRepositoryMockGetAllExpectation
-	expectations       []*ArticleRepositoryMockGetAllExpectation
-
-	callArgs []*ArticleRepositoryMockGetAllParams
-	mutex    sync.RWMutex
-}
-
-// ArticleRepositoryMockGetAllExpectation specifies expectation struct of the ArticleRepository.GetAll
-type ArticleRepositoryMockGetAllExpectation struct {
-	mock    *ArticleRepositoryMock
-	params  *ArticleRepositoryMockGetAllParams
-	results *ArticleRepositoryMockGetAllResults
-	Counter uint64
-}
-
-// ArticleRepositoryMockGetAllParams contains parameters of the ArticleRepository.GetAll
-type ArticleRepositoryMockGetAllParams struct {
-	ctx context.Context
-}
-
-// ArticleRepositoryMockGetAllResults contains results of the ArticleRepository.GetAll
-type ArticleRepositoryMockGetAllResults struct {
-	aa1 []models.Article
-	err error
-}
-
-// Expect sets up expected params for ArticleRepository.GetAll
-func (mmGetAll *mArticleRepositoryMockGetAll) Expect(ctx context.Context) *mArticleRepositoryMockGetAll {
-	if mmGetAll.mock.funcGetAll != nil {
-		mmGetAll.mock.t.Fatalf("ArticleRepositoryMock.GetAll mock is already set by Set")
-	}
-
-	if mmGetAll.defaultExpectation == nil {
-		mmGetAll.defaultExpectation = &ArticleRepositoryMockGetAllExpectation{}
-	}
-
-	mmGetAll.defaultExpectation.params = &ArticleRepositoryMockGetAllParams{ctx}
-	for _, e := range mmGetAll.expectations {
-		if minimock.Equal(e.params, mmGetAll.defaultExpectation.params) {
-			mmGetAll.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAll.defaultExpectation.params)
-		}
-	}
-
-	return mmGetAll
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetAll
-func (mmGetAll *mArticleRepositoryMockGetAll) Inspect(f func(ctx context.Context)) *mArticleRepositoryMockGetAll {
-	if mmGetAll.mock.inspectFuncGetAll != nil {
-		mmGetAll.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetAll")
-	}
-
-	mmGetAll.mock.inspectFuncGetAll = f
-
-	return mmGetAll
-}
-
-// Return sets up results that will be returned by ArticleRepository.GetAll
-func (mmGetAll *mArticleRepositoryMockGetAll) Return(aa1 []models.Article, err error) *ArticleRepositoryMock {
-	if mmGetAll.mock.funcGetAll != nil {
-		mmGetAll.mock.t.Fatalf("ArticleRepositoryMock.GetAll mock is already set by Set")
-	}
-
-	if mmGetAll.defaultExpectation == nil {
-		mmGetAll.defaultExpectation = &ArticleRepositoryMockGetAllExpectation{mock: mmGetAll.mock}
-	}
-	mmGetAll.defaultExpectation.results = &ArticleRepositoryMockGetAllResults{aa1, err}
-	return mmGetAll.mock
-}
-
-// Set uses given function f to mock the ArticleRepository.GetAll method
-func (mmGetAll *mArticleRepositoryMockGetAll) Set(f func(ctx context.Context) (aa1 []models.Article, err error)) *ArticleRepositoryMock {
-	if mmGetAll.defaultExpectation != nil {
-		mmGetAll.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetAll method")
-	}
-
-	if len(mmGetAll.expectations) > 0 {
-		mmGetAll.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetAll method")
-	}
-
-	mmGetAll.mock.funcGetAll = f
-	return mmGetAll.mock
-}
-
-// When sets expectation for the ArticleRepository.GetAll which will trigger the result defined by the following
-// Then helper
-func (mmGetAll *mArticleRepositoryMockGetAll) When(ctx context.Context) *ArticleRepositoryMockGetAllExpectation {
-	if mmGetAll.mock.funcGetAll != nil {
-		mmGetAll.mock.t.Fatalf("ArticleRepositoryMock.GetAll mock is already set by Set")
-	}
-
-	expectation := &ArticleRepositoryMockGetAllExpectation{
-		mock:   mmGetAll.mock,
-		params: &ArticleRepositoryMockGetAllParams{ctx},
-	}
-	mmGetAll.expectations = append(mmGetAll.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleRepository.GetAll return parameters for the expectation previously defined by the When method
-func (e *ArticleRepositoryMockGetAllExpectation) Then(aa1 []models.Article, err error) *ArticleRepositoryMock {
-	e.results = &ArticleRepositoryMockGetAllResults{aa1, err}
-	return e.mock
-}
-
-// GetAll implements interfaces.ArticleRepository
-func (mmGetAll *ArticleRepositoryMock) GetAll(ctx context.Context) (aa1 []models.Article, err error) {
-	mm_atomic.AddUint64(&mmGetAll.beforeGetAllCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetAll.afterGetAllCounter, 1)
-
-	if mmGetAll.inspectFuncGetAll != nil {
-		mmGetAll.inspectFuncGetAll(ctx)
-	}
-
-	mm_params := &ArticleRepositoryMockGetAllParams{ctx}
-
-	// Record call args
-	mmGetAll.GetAllMock.mutex.Lock()
-	mmGetAll.GetAllMock.callArgs = append(mmGetAll.GetAllMock.callArgs, mm_params)
-	mmGetAll.GetAllMock.mutex.Unlock()
-
-	for _, e := range mmGetAll.GetAllMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.aa1, e.results.err
-		}
-	}
-
-	if mmGetAll.GetAllMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetAll.GetAllMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetAll.GetAllMock.defaultExpectation.params
-		mm_got := ArticleRepositoryMockGetAllParams{ctx}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetAll.t.Errorf("ArticleRepositoryMock.GetAll got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetAll.GetAllMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetAll.t.Fatal("No results are set for the ArticleRepositoryMock.GetAll")
-		}
-		return (*mm_results).aa1, (*mm_results).err
-	}
-	if mmGetAll.funcGetAll != nil {
-		return mmGetAll.funcGetAll(ctx)
-	}
-	mmGetAll.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetAll. %v", ctx)
-	return
-}
-
-// GetAllAfterCounter returns a count of finished ArticleRepositoryMock.GetAll invocations
-func (mmGetAll *ArticleRepositoryMock) GetAllAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetAll.afterGetAllCounter)
-}
-
-// GetAllBeforeCounter returns a count of ArticleRepositoryMock.GetAll invocations
-func (mmGetAll *ArticleRepositoryMock) GetAllBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetAll.beforeGetAllCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetAll.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetAll *mArticleRepositoryMockGetAll) Calls() []*ArticleRepositoryMockGetAllParams {
-	mmGetAll.mutex.RLock()
-
-	argCopy := make([]*ArticleRepositoryMockGetAllParams, len(mmGetAll.callArgs))
-	copy(argCopy, mmGetAll.callArgs)
-
-	mmGetAll.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetAllDone returns true if the count of the GetAll invocations corresponds
-// the number of defined expectations
-func (m *ArticleRepositoryMock) MinimockGetAllDone() bool {
-	for _, e := range m.GetAllMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetAll != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetAllInspect logs each unmet expectation
-func (m *ArticleRepositoryMock) MinimockGetAllInspect() {
-	for _, e := range m.GetAllMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetAll with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
-		if m.GetAllMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleRepositoryMock.GetAll")
-		} else {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetAll with params: %#v", *m.GetAllMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetAll != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
-		m.t.Error("Expected call to ArticleRepositoryMock.GetAll")
-	}
-}
-
-type mArticleRepositoryMockGetAllPreview struct {
-	mock               *ArticleRepositoryMock
-	defaultExpectation *ArticleRepositoryMockGetAllPreviewExpectation
-	expectations       []*ArticleRepositoryMockGetAllPreviewExpectation
-
-	callArgs []*ArticleRepositoryMockGetAllPreviewParams
-	mutex    sync.RWMutex
-}
-
-// ArticleRepositoryMockGetAllPreviewExpectation specifies expectation struct of the ArticleRepository.GetAllPreview
-type ArticleRepositoryMockGetAllPreviewExpectation struct {
-	mock    *ArticleRepositoryMock
-	params  *ArticleRepositoryMockGetAllPreviewParams
-	results *ArticleRepositoryMockGetAllPreviewResults
-	Counter uint64
-}
-
-// ArticleRepositoryMockGetAllPreviewParams contains parameters of the ArticleRepository.GetAllPreview
-type ArticleRepositoryMockGetAllPreviewParams struct {
-	ctx context.Context
-}
-
-// ArticleRepositoryMockGetAllPreviewResults contains results of the ArticleRepository.GetAllPreview
-type ArticleRepositoryMockGetAllPreviewResults struct {
-	aa1 []models.ArticlePreview
-	err error
-}
-
-// Expect sets up expected params for ArticleRepository.GetAllPreview
-func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Expect(ctx context.Context) *mArticleRepositoryMockGetAllPreview {
-	if mmGetAllPreview.mock.funcGetAllPreview != nil {
-		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
-	}
-
-	if mmGetAllPreview.defaultExpectation == nil {
-		mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{}
-	}
-
-	mmGetAllPreview.defaultExpectation.params = &ArticleRepositoryMockGetAllPreviewParams{ctx}
-	for _, e := range mmGetAllPreview.expectations {
-		if minimock.Equal(e.params, mmGetAllPreview.defaultExpectation.params) {
-			mmGetAllPreview.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllPreview.defaultExpectation.params)
-		}
-	}
-
-	return mmGetAllPreview
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetAllPreview
-func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Inspect(f func(ctx context.Context)) *mArticleRepositoryMockGetAllPreview {
-	if mmGetAllPreview.mock.inspectFuncGetAllPreview != nil {
-		mmGetAllPreview.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetAllPreview")
-	}
-
-	mmGetAllPreview.mock.inspectFuncGetAllPreview = f
-
-	return mmGetAllPreview
-}
-
-// Return sets up results that will be returned by ArticleRepository.GetAllPreview
-func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
-	if mmGetAllPreview.mock.funcGetAllPreview != nil {
-		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
-	}
-
-	if mmGetAllPreview.defaultExpectation == nil {
-		mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{mock: mmGetAllPreview.mock}
-	}
-	mmGetAllPreview.defaultExpectation.results = &ArticleRepositoryMockGetAllPreviewResults{aa1, err}
-	return mmGetAllPreview.mock
-}
-
-// Set uses given function f to mock the ArticleRepository.GetAllPreview method
-func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Set(f func(ctx context.Context) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock {
-	if mmGetAllPreview.defaultExpectation != nil {
-		mmGetAllPreview.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetAllPreview method")
-	}
-
-	if len(mmGetAllPreview.expectations) > 0 {
-		mmGetAllPreview.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetAllPreview method")
-	}
-
-	mmGetAllPreview.mock.funcGetAllPreview = f
-	return mmGetAllPreview.mock
-}
-
-// When sets expectation for the ArticleRepository.GetAllPreview which will trigger the result defined by the following
-// Then helper
-func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) When(ctx context.Context) *ArticleRepositoryMockGetAllPreviewExpectation {
-	if mmGetAllPreview.mock.funcGetAllPreview != nil {
-		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
-	}
-
-	expectation := &ArticleRepositoryMockGetAllPreviewExpectation{
-		mock:   mmGetAllPreview.mock,
-		params: &ArticleRepositoryMockGetAllPreviewParams{ctx},
-	}
-	mmGetAllPreview.expectations = append(mmGetAllPreview.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleRepository.GetAllPreview return parameters for the expectation previously defined by the When method
-func (e *ArticleRepositoryMockGetAllPreviewExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
-	e.results = &ArticleRepositoryMockGetAllPreviewResults{aa1, err}
-	return e.mock
-}
-
-// GetAllPreview implements interfaces.ArticleRepository
-func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreview(ctx context.Context) (aa1 []models.ArticlePreview, err error) {
-	mm_atomic.AddUint64(&mmGetAllPreview.beforeGetAllPreviewCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetAllPreview.afterGetAllPreviewCounter, 1)
-
-	if mmGetAllPreview.inspectFuncGetAllPreview != nil {
-		mmGetAllPreview.inspectFuncGetAllPreview(ctx)
-	}
-
-	mm_params := &ArticleRepositoryMockGetAllPreviewParams{ctx}
-
-	// Record call args
-	mmGetAllPreview.GetAllPreviewMock.mutex.Lock()
-	mmGetAllPreview.GetAllPreviewMock.callArgs = append(mmGetAllPreview.GetAllPreviewMock.callArgs, mm_params)
-	mmGetAllPreview.GetAllPreviewMock.mutex.Unlock()
-
-	for _, e := range mmGetAllPreview.GetAllPreviewMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.aa1, e.results.err
-		}
-	}
-
-	if mmGetAllPreview.GetAllPreviewMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetAllPreview.GetAllPreviewMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.params
-		mm_got := ArticleRepositoryMockGetAllPreviewParams{ctx}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetAllPreview.t.Errorf("ArticleRepositoryMock.GetAllPreview got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetAllPreview.t.Fatal("No results are set for the ArticleRepositoryMock.GetAllPreview")
-		}
-		return (*mm_results).aa1, (*mm_results).err
-	}
-	if mmGetAllPreview.funcGetAllPreview != nil {
-		return mmGetAllPreview.funcGetAllPreview(ctx)
-	}
-	mmGetAllPreview.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetAllPreview. %v", ctx)
-	return
-}
-
-// GetAllPreviewAfterCounter returns a count of finished ArticleRepositoryMock.GetAllPreview invocations
-func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreviewAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetAllPreview.afterGetAllPreviewCounter)
-}
-
-// GetAllPreviewBeforeCounter returns a count of ArticleRepositoryMock.GetAllPreview invocations
-func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreviewBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetAllPreview.beforeGetAllPreviewCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetAllPreview.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Calls() []*ArticleRepositoryMockGetAllPreviewParams {
-	mmGetAllPreview.mutex.RLock()
-
-	argCopy := make([]*ArticleRepositoryMockGetAllPreviewParams, len(mmGetAllPreview.callArgs))
-	copy(argCopy, mmGetAllPreview.callArgs)
-
-	mmGetAllPreview.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetAllPreviewDone returns true if the count of the GetAllPreview invocations corresponds
-// the number of defined expectations
-func (m *ArticleRepositoryMock) MinimockGetAllPreviewDone() bool {
-	for _, e := range m.GetAllPreviewMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetAllPreviewMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetAllPreview != nil && mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetAllPreviewInspect logs each unmet expectation
-func (m *ArticleRepositoryMock) MinimockGetAllPreviewInspect() {
-	for _, e := range m.GetAllPreviewMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetAllPreview with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetAllPreviewMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) < 1 {
-		if m.GetAllPreviewMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleRepositoryMock.GetAllPreview")
-		} else {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetAllPreview with params: %#v", *m.GetAllPreviewMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetAllPreview != nil && mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter) < 1 {
-		m.t.Error("Expected call to ArticleRepositoryMock.GetAllPreview")
-	}
-}
-
-type mArticleRepositoryMockGetByID struct {
-	mock               *ArticleRepositoryMock
-	defaultExpectation *ArticleRepositoryMockGetByIDExpectation
-	expectations       []*ArticleRepositoryMockGetByIDExpectation
-
-	callArgs []*ArticleRepositoryMockGetByIDParams
-	mutex    sync.RWMutex
-}
-
-// ArticleRepositoryMockGetByIDExpectation specifies expectation struct of the ArticleRepository.GetByID
-type ArticleRepositoryMockGetByIDExpectation struct {
-	mock    *ArticleRepositoryMock
-	params  *ArticleRepositoryMockGetByIDParams
-	results *ArticleRepositoryMockGetByIDResults
-	Counter uint64
-}
-
-// ArticleRepositoryMockGetByIDParams contains parameters of the ArticleRepository.GetByID
-type ArticleRepositoryMockGetByIDParams struct {
-	ctx context.Context
-	ID  int
-}
-
-// ArticleRepositoryMockGetByIDResults contains results of the ArticleRepository.GetByID
-type ArticleRepositoryMockGetByIDResults struct {
-	ap1 *models.Article
-	err error
-}
-
-// Expect sets up expected params for ArticleRepository.GetByID
-func (mmGetByID *mArticleRepositoryMockGetByID) Expect(ctx context.Context, ID int) *mArticleRepositoryMockGetByID {
-	if mmGetByID.mock.funcGetByID != nil {
-		mmGetByID.mock.t.Fatalf("ArticleRepositoryMock.GetByID mock is already set by Set")
-	}
-
-	if mmGetByID.defaultExpectation == nil {
-		mmGetByID.defaultExpectation = &ArticleRepositoryMockGetByIDExpectation{}
-	}
-
-	mmGetByID.defaultExpectation.params = &ArticleRepositoryMockGetByIDParams{ctx, ID}
-	for _, e := range mmGetByID.expectations {
-		if minimock.Equal(e.params, mmGetByID.defaultExpectation.params) {
-			mmGetByID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByID.defaultExpectation.params)
-		}
-	}
-
-	return mmGetByID
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetByID
-func (mmGetByID *mArticleRepositoryMockGetByID) Inspect(f func(ctx context.Context, ID int)) *mArticleRepositoryMockGetByID {
-	if mmGetByID.mock.inspectFuncGetByID != nil {
-		mmGetByID.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetByID")
-	}
-
-	mmGetByID.mock.inspectFuncGetByID = f
-
-	return mmGetByID
-}
-
-// Return sets up results that will be returned by ArticleRepository.GetByID
-func (mmGetByID *mArticleRepositoryMockGetByID) Return(ap1 *models.Article, err error) *ArticleRepositoryMock {
-	if mmGetByID.mock.funcGetByID != nil {
-		mmGetByID.mock.t.Fatalf("ArticleRepositoryMock.GetByID mock is already set by Set")
-	}
-
-	if mmGetByID.defaultExpectation == nil {
-		mmGetByID.defaultExpectation = &ArticleRepositoryMockGetByIDExpectation{mock: mmGetByID.mock}
-	}
-	mmGetByID.defaultExpectation.results = &ArticleRepositoryMockGetByIDResults{ap1, err}
-	return mmGetByID.mock
-}
-
-// Set uses given function f to mock the ArticleRepository.GetByID method
-func (mmGetByID *mArticleRepositoryMockGetByID) Set(f func(ctx context.Context, ID int) (ap1 *models.Article, err error)) *ArticleRepositoryMock {
-	if mmGetByID.defaultExpectation != nil {
-		mmGetByID.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetByID method")
-	}
-
-	if len(mmGetByID.expectations) > 0 {
-		mmGetByID.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetByID method")
-	}
-
-	mmGetByID.mock.funcGetByID = f
-	return mmGetByID.mock
-}
-
-// When sets expectation for the ArticleRepository.GetByID which will trigger the result defined by the following
-// Then helper
-func (mmGetByID *mArticleRepositoryMockGetByID) When(ctx context.Context, ID int) *ArticleRepositoryMockGetByIDExpectation {
-	if mmGetByID.mock.funcGetByID != nil {
-		mmGetByID.mock.t.Fatalf("ArticleRepositoryMock.GetByID mock is already set by Set")
-	}
-
-	expectation := &ArticleRepositoryMockGetByIDExpectation{
-		mock:   mmGetByID.mock,
-		params: &ArticleRepositoryMockGetByIDParams{ctx, ID},
-	}
-	mmGetByID.expectations = append(mmGetByID.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleRepository.GetByID return parameters for the expectation previously defined by the When method
-func (e *ArticleRepositoryMockGetByIDExpectation) Then(ap1 *models.Article, err error) *ArticleRepositoryMock {
-	e.results = &ArticleRepositoryMockGetByIDResults{ap1, err}
-	return e.mock
-}
-
-// GetByID implements interfaces.ArticleRepository
-func (mmGetByID *ArticleRepositoryMock) GetByID(ctx context.Context, ID int) (ap1 *models.Article, err error) {
-	mm_atomic.AddUint64(&mmGetByID.beforeGetByIDCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetByID.afterGetByIDCounter, 1)
-
-	if mmGetByID.inspectFuncGetByID != nil {
-		mmGetByID.inspectFuncGetByID(ctx, ID)
-	}
-
-	mm_params := &ArticleRepositoryMockGetByIDParams{ctx, ID}
-
-	// Record call args
-	mmGetByID.GetByIDMock.mutex.Lock()
-	mmGetByID.GetByIDMock.callArgs = append(mmGetByID.GetByIDMock.callArgs, mm_params)
-	mmGetByID.GetByIDMock.mutex.Unlock()
-
-	for _, e := range mmGetByID.GetByIDMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.ap1, e.results.err
-		}
-	}
-
-	if mmGetByID.GetByIDMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetByID.GetByIDMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetByID.GetByIDMock.defaultExpectation.params
-		mm_got := ArticleRepositoryMockGetByIDParams{ctx, ID}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetByID.t.Errorf("ArticleRepositoryMock.GetByID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetByID.GetByIDMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetByID.t.Fatal("No results are set for the ArticleRepositoryMock.GetByID")
-		}
-		return (*mm_results).ap1, (*mm_results).err
-	}
-	if mmGetByID.funcGetByID != nil {
-		return mmGetByID.funcGetByID(ctx, ID)
-	}
-	mmGetByID.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetByID. %v %v", ctx, ID)
-	return
-}
-
-// GetByIDAfterCounter returns a count of finished ArticleRepositoryMock.GetByID invocations
-func (mmGetByID *ArticleRepositoryMock) GetByIDAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByID.afterGetByIDCounter)
-}
-
-// GetByIDBeforeCounter returns a count of ArticleRepositoryMock.GetByID invocations
-func (mmGetByID *ArticleRepositoryMock) GetByIDBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByID.beforeGetByIDCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetByID.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetByID *mArticleRepositoryMockGetByID) Calls() []*ArticleRepositoryMockGetByIDParams {
-	mmGetByID.mutex.RLock()
-
-	argCopy := make([]*ArticleRepositoryMockGetByIDParams, len(mmGetByID.callArgs))
-	copy(argCopy, mmGetByID.callArgs)
-
-	mmGetByID.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetByIDDone returns true if the count of the GetByID invocations corresponds
-// the number of defined expectations
-func (m *ArticleRepositoryMock) MinimockGetByIDDone() bool {
-	for _, e := range m.GetByIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByID != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetByIDInspect logs each unmet expectation
-func (m *ArticleRepositoryMock) MinimockGetByIDInspect() {
-	for _, e := range m.GetByIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetByID with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
-		if m.GetByIDMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleRepositoryMock.GetByID")
-		} else {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetByID with params: %#v", *m.GetByIDMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByID != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
-		m.t.Error("Expected call to ArticleRepositoryMock.GetByID")
-	}
-}
-
-type mArticleRepositoryMockGetByURL struct {
-	mock               *ArticleRepositoryMock
-	defaultExpectation *ArticleRepositoryMockGetByURLExpectation
-	expectations       []*ArticleRepositoryMockGetByURLExpectation
-
-	callArgs []*ArticleRepositoryMockGetByURLParams
-	mutex    sync.RWMutex
-}
-
-// ArticleRepositoryMockGetByURLExpectation specifies expectation struct of the ArticleRepository.GetByURL
-type ArticleRepositoryMockGetByURLExpectation struct {
-	mock    *ArticleRepositoryMock
-	params  *ArticleRepositoryMockGetByURLParams
-	results *ArticleRepositoryMockGetByURLResults
-	Counter uint64
-}
-
-// ArticleRepositoryMockGetByURLParams contains parameters of the ArticleRepository.GetByURL
-type ArticleRepositoryMockGetByURLParams struct {
-	ctx context.Context
-	url string
-}
-
-// ArticleRepositoryMockGetByURLResults contains results of the ArticleRepository.GetByURL
-type ArticleRepositoryMockGetByURLResults struct {
-	ap1 *models.Article
-	err error
-}
-
-// Expect sets up expected params for ArticleRepository.GetByURL
-func (mmGetByURL *mArticleRepositoryMockGetByURL) Expect(ctx context.Context, url string) *mArticleRepositoryMockGetByURL {
-	if mmGetByURL.mock.funcGetByURL != nil {
-		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
-	}
-
-	if mmGetByURL.defaultExpectation == nil {
-		mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
-	}
-
-	mmGetByURL.defaultExpectation.params = &ArticleRepositoryMockGetByURLParams{ctx, url}
-	for _, e := range mmGetByURL.expectations {
-		if minimock.Equal(e.params, mmGetByURL.defaultExpectation.params) {
-			mmGetByURL.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByURL.defaultExpectation.params)
-		}
-	}
-
-	return mmGetByURL
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetByURL
-func (mmGetByURL *mArticleRepositoryMockGetByURL) Inspect(f func(ctx context.Context, url string)) *mArticleRepositoryMockGetByURL {
-	if mmGetByURL.mock.inspectFuncGetByURL != nil {
-		mmGetByURL.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetByURL")
-	}
-
-	mmGetByURL.mock.inspectFuncGetByURL = f
-
-	return mmGetByURL
-}
-
-// Return sets up results that will be returned by ArticleRepository.GetByURL
-func (mmGetByURL *mArticleRepositoryMockGetByURL) Return(ap1 *models.Article, err error) *ArticleRepositoryMock {
-	if mmGetByURL.mock.funcGetByURL != nil {
-		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
-	}
-
-	if mmGetByURL.defaultExpectation == nil {
-		mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock}
-	}
-	mmGetByURL.defaultExpectation.results = &ArticleRepositoryMockGetByURLResults{ap1, err}
-	return mmGetByURL.mock
-}
-
-// Set uses given function f to mock the ArticleRepository.GetByURL method
-func (mmGetByURL *mArticleRepositoryMockGetByURL) Set(f func(ctx context.Context, url string) (ap1 *models.Article, err error)) *ArticleRepositoryMock {
-	if mmGetByURL.defaultExpectation != nil {
-		mmGetByURL.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetByURL method")
-	}
-
-	if len(mmGetByURL.expectations) > 0 {
-		mmGetByURL.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetByURL method")
-	}
-
-	mmGetByURL.mock.funcGetByURL = f
-	return mmGetByURL.mock
-}
-
-// When sets expectation for the ArticleRepository.GetByURL which will trigger the result defined by the following
-// Then helper
-func (mmGetByURL *mArticleRepositoryMockGetByURL) When(ctx context.Context, url string) *ArticleRepositoryMockGetByURLExpectation {
-	if mmGetByURL.mock.funcGetByURL != nil {
-		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
-	}
-
-	expectation := &ArticleRepositoryMockGetByURLExpectation{
-		mock:   mmGetByURL.mock,
-		params: &ArticleRepositoryMockGetByURLParams{ctx, url},
-	}
-	mmGetByURL.expectations = append(mmGetByURL.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleRepository.GetByURL return parameters for the expectation previously defined by the When method
-func (e *ArticleRepositoryMockGetByURLExpectation) Then(ap1 *models.Article, err error) *ArticleRepositoryMock {
-	e.results = &ArticleRepositoryMockGetByURLResults{ap1, err}
-	return e.mock
-}
-
-// GetByURL implements interfaces.ArticleRepository
-func (mmGetByURL *ArticleRepositoryMock) GetByURL(ctx context.Context, url string) (ap1 *models.Article, err error) {
-	mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1)
-
-	if mmGetByURL.inspectFuncGetByURL != nil {
-		mmGetByURL.inspectFuncGetByURL(ctx, url)
-	}
-
-	mm_params := &ArticleRepositoryMockGetByURLParams{ctx, url}
-
-	// Record call args
-	mmGetByURL.GetByURLMock.mutex.Lock()
-	mmGetByURL.GetByURLMock.callArgs = append(mmGetByURL.GetByURLMock.callArgs, mm_params)
-	mmGetByURL.GetByURLMock.mutex.Unlock()
-
-	for _, e := range mmGetByURL.GetByURLMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.ap1, e.results.err
-		}
-	}
-
-	if mmGetByURL.GetByURLMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetByURL.GetByURLMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetByURL.GetByURLMock.defaultExpectation.params
-		mm_got := ArticleRepositoryMockGetByURLParams{ctx, url}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetByURL.t.Fatal("No results are set for the ArticleRepositoryMock.GetByURL")
-		}
-		return (*mm_results).ap1, (*mm_results).err
-	}
-	if mmGetByURL.funcGetByURL != nil {
-		return mmGetByURL.funcGetByURL(ctx, url)
-	}
-	mmGetByURL.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetByURL. %v %v", ctx, url)
-	return
-}
-
-// GetByURLAfterCounter returns a count of finished ArticleRepositoryMock.GetByURL invocations
-func (mmGetByURL *ArticleRepositoryMock) GetByURLAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter)
-}
-
-// GetByURLBeforeCounter returns a count of ArticleRepositoryMock.GetByURL invocations
-func (mmGetByURL *ArticleRepositoryMock) GetByURLBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetByURL.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetByURL *mArticleRepositoryMockGetByURL) Calls() []*ArticleRepositoryMockGetByURLParams {
-	mmGetByURL.mutex.RLock()
-
-	argCopy := make([]*ArticleRepositoryMockGetByURLParams, len(mmGetByURL.callArgs))
-	copy(argCopy, mmGetByURL.callArgs)
-
-	mmGetByURL.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetByURLDone returns true if the count of the GetByURL invocations corresponds
-// the number of defined expectations
-func (m *ArticleRepositoryMock) MinimockGetByURLDone() bool {
-	for _, e := range m.GetByURLMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByURLMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByURL != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetByURLInspect logs each unmet expectation
-func (m *ArticleRepositoryMock) MinimockGetByURLInspect() {
-	for _, e := range m.GetByURLMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetByURL with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByURLMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
-		if m.GetByURLMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleRepositoryMock.GetByURL")
-		} else {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetByURL with params: %#v", *m.GetByURLMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByURL != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
-		m.t.Error("Expected call to ArticleRepositoryMock.GetByURL")
-	}
-}
-
-type mArticleRepositoryMockGetPreviewByTagID struct {
-	mock               *ArticleRepositoryMock
-	defaultExpectation *ArticleRepositoryMockGetPreviewByTagIDExpectation
-	expectations       []*ArticleRepositoryMockGetPreviewByTagIDExpectation
-
-	callArgs []*ArticleRepositoryMockGetPreviewByTagIDParams
-	mutex    sync.RWMutex
-}
-
-// ArticleRepositoryMockGetPreviewByTagIDExpectation specifies expectation struct of the ArticleRepository.GetPreviewByTagID
-type ArticleRepositoryMockGetPreviewByTagIDExpectation struct {
-	mock    *ArticleRepositoryMock
-	params  *ArticleRepositoryMockGetPreviewByTagIDParams
-	results *ArticleRepositoryMockGetPreviewByTagIDResults
-	Counter uint64
-}
-
-// ArticleRepositoryMockGetPreviewByTagIDParams contains parameters of the ArticleRepository.GetPreviewByTagID
-type ArticleRepositoryMockGetPreviewByTagIDParams struct {
-	ctx   context.Context
-	tagID int
-}
-
-// ArticleRepositoryMockGetPreviewByTagIDResults contains results of the ArticleRepository.GetPreviewByTagID
-type ArticleRepositoryMockGetPreviewByTagIDResults struct {
-	aa1 []models.ArticlePreview
-	err error
-}
-
-// Expect sets up expected params for ArticleRepository.GetPreviewByTagID
-func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Expect(ctx context.Context, tagID int) *mArticleRepositoryMockGetPreviewByTagID {
-	if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
-		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
-	}
-
-	if mmGetPreviewByTagID.defaultExpectation == nil {
-		mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
-	}
-
-	mmGetPreviewByTagID.defaultExpectation.params = &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
-	for _, e := range mmGetPreviewByTagID.expectations {
-		if minimock.Equal(e.params, mmGetPreviewByTagID.defaultExpectation.params) {
-			mmGetPreviewByTagID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetPreviewByTagID.defaultExpectation.params)
-		}
-	}
-
-	return mmGetPreviewByTagID
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetPreviewByTagID
-func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Inspect(f func(ctx context.Context, tagID int)) *mArticleRepositoryMockGetPreviewByTagID {
-	if mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID != nil {
-		mmGetPreviewByTagID.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetPreviewByTagID")
-	}
-
-	mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID = f
-
-	return mmGetPreviewByTagID
-}
-
-// Return sets up results that will be returned by ArticleRepository.GetPreviewByTagID
-func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
-	if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
-		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
-	}
-
-	if mmGetPreviewByTagID.defaultExpectation == nil {
-		mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{mock: mmGetPreviewByTagID.mock}
-	}
-	mmGetPreviewByTagID.defaultExpectation.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err}
-	return mmGetPreviewByTagID.mock
-}
-
-// Set uses given function f to mock the ArticleRepository.GetPreviewByTagID method
-func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Set(f func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock {
-	if mmGetPreviewByTagID.defaultExpectation != nil {
-		mmGetPreviewByTagID.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetPreviewByTagID method")
-	}
-
-	if len(mmGetPreviewByTagID.expectations) > 0 {
-		mmGetPreviewByTagID.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetPreviewByTagID method")
-	}
-
-	mmGetPreviewByTagID.mock.funcGetPreviewByTagID = f
-	return mmGetPreviewByTagID.mock
-}
-
-// When sets expectation for the ArticleRepository.GetPreviewByTagID which will trigger the result defined by the following
-// Then helper
-func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) When(ctx context.Context, tagID int) *ArticleRepositoryMockGetPreviewByTagIDExpectation {
-	if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
-		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
-	}
-
-	expectation := &ArticleRepositoryMockGetPreviewByTagIDExpectation{
-		mock:   mmGetPreviewByTagID.mock,
-		params: &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID},
-	}
-	mmGetPreviewByTagID.expectations = append(mmGetPreviewByTagID.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleRepository.GetPreviewByTagID return parameters for the expectation previously defined by the When method
-func (e *ArticleRepositoryMockGetPreviewByTagIDExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
-	e.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err}
-	return e.mock
-}
-
-// GetPreviewByTagID implements interfaces.ArticleRepository
-func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagID(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error) {
-	mm_atomic.AddUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter, 1)
-
-	if mmGetPreviewByTagID.inspectFuncGetPreviewByTagID != nil {
-		mmGetPreviewByTagID.inspectFuncGetPreviewByTagID(ctx, tagID)
-	}
-
-	mm_params := &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
-
-	// Record call args
-	mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Lock()
-	mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs = append(mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs, mm_params)
-	mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Unlock()
-
-	for _, e := range mmGetPreviewByTagID.GetPreviewByTagIDMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.aa1, e.results.err
-		}
-	}
-
-	if mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.params
-		mm_got := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetPreviewByTagID.t.Fatal("No results are set for the ArticleRepositoryMock.GetPreviewByTagID")
-		}
-		return (*mm_results).aa1, (*mm_results).err
-	}
-	if mmGetPreviewByTagID.funcGetPreviewByTagID != nil {
-		return mmGetPreviewByTagID.funcGetPreviewByTagID(ctx, tagID)
-	}
-	mmGetPreviewByTagID.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetPreviewByTagID. %v %v", ctx, tagID)
-	return
-}
-
-// GetPreviewByTagIDAfterCounter returns a count of finished ArticleRepositoryMock.GetPreviewByTagID invocations
-func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter)
-}
-
-// GetPreviewByTagIDBeforeCounter returns a count of ArticleRepositoryMock.GetPreviewByTagID invocations
-func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetPreviewByTagID.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Calls() []*ArticleRepositoryMockGetPreviewByTagIDParams {
-	mmGetPreviewByTagID.mutex.RLock()
-
-	argCopy := make([]*ArticleRepositoryMockGetPreviewByTagIDParams, len(mmGetPreviewByTagID.callArgs))
-	copy(argCopy, mmGetPreviewByTagID.callArgs)
-
-	mmGetPreviewByTagID.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetPreviewByTagIDDone returns true if the count of the GetPreviewByTagID invocations corresponds
-// the number of defined expectations
-func (m *ArticleRepositoryMock) MinimockGetPreviewByTagIDDone() bool {
-	for _, e := range m.GetPreviewByTagIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetPreviewByTagIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetPreviewByTagID != nil && mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetPreviewByTagIDInspect logs each unmet expectation
-func (m *ArticleRepositoryMock) MinimockGetPreviewByTagIDInspect() {
-	for _, e := range m.GetPreviewByTagIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetPreviewByTagID with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetPreviewByTagIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) < 1 {
-		if m.GetPreviewByTagIDMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID")
-		} else {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.GetPreviewByTagID with params: %#v", *m.GetPreviewByTagIDMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetPreviewByTagID != nil && mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter) < 1 {
-		m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID")
-	}
-}
-
-type mArticleRepositoryMockUpdate struct {
-	mock               *ArticleRepositoryMock
-	defaultExpectation *ArticleRepositoryMockUpdateExpectation
-	expectations       []*ArticleRepositoryMockUpdateExpectation
-
-	callArgs []*ArticleRepositoryMockUpdateParams
-	mutex    sync.RWMutex
-}
-
-// ArticleRepositoryMockUpdateExpectation specifies expectation struct of the ArticleRepository.Update
-type ArticleRepositoryMockUpdateExpectation struct {
-	mock    *ArticleRepositoryMock
-	params  *ArticleRepositoryMockUpdateParams
-	results *ArticleRepositoryMockUpdateResults
-	Counter uint64
-}
-
-// ArticleRepositoryMockUpdateParams contains parameters of the ArticleRepository.Update
-type ArticleRepositoryMockUpdateParams struct {
-	ctx context.Context
-	m   models.Article
-}
-
-// ArticleRepositoryMockUpdateResults contains results of the ArticleRepository.Update
-type ArticleRepositoryMockUpdateResults struct {
-	err error
-}
-
-// Expect sets up expected params for ArticleRepository.Update
-func (mmUpdate *mArticleRepositoryMockUpdate) Expect(ctx context.Context, m models.Article) *mArticleRepositoryMockUpdate {
-	if mmUpdate.mock.funcUpdate != nil {
-		mmUpdate.mock.t.Fatalf("ArticleRepositoryMock.Update mock is already set by Set")
-	}
-
-	if mmUpdate.defaultExpectation == nil {
-		mmUpdate.defaultExpectation = &ArticleRepositoryMockUpdateExpectation{}
-	}
-
-	mmUpdate.defaultExpectation.params = &ArticleRepositoryMockUpdateParams{ctx, m}
-	for _, e := range mmUpdate.expectations {
-		if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
-			mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
-		}
-	}
-
-	return mmUpdate
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleRepository.Update
-func (mmUpdate *mArticleRepositoryMockUpdate) Inspect(f func(ctx context.Context, m models.Article)) *mArticleRepositoryMockUpdate {
-	if mmUpdate.mock.inspectFuncUpdate != nil {
-		mmUpdate.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.Update")
-	}
-
-	mmUpdate.mock.inspectFuncUpdate = f
-
-	return mmUpdate
-}
-
-// Return sets up results that will be returned by ArticleRepository.Update
-func (mmUpdate *mArticleRepositoryMockUpdate) Return(err error) *ArticleRepositoryMock {
-	if mmUpdate.mock.funcUpdate != nil {
-		mmUpdate.mock.t.Fatalf("ArticleRepositoryMock.Update mock is already set by Set")
-	}
-
-	if mmUpdate.defaultExpectation == nil {
-		mmUpdate.defaultExpectation = &ArticleRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
-	}
-	mmUpdate.defaultExpectation.results = &ArticleRepositoryMockUpdateResults{err}
-	return mmUpdate.mock
-}
-
-// Set uses given function f to mock the ArticleRepository.Update method
-func (mmUpdate *mArticleRepositoryMockUpdate) Set(f func(ctx context.Context, m models.Article) (err error)) *ArticleRepositoryMock {
-	if mmUpdate.defaultExpectation != nil {
-		mmUpdate.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.Update method")
-	}
-
-	if len(mmUpdate.expectations) > 0 {
-		mmUpdate.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.Update method")
-	}
-
-	mmUpdate.mock.funcUpdate = f
-	return mmUpdate.mock
-}
-
-// When sets expectation for the ArticleRepository.Update which will trigger the result defined by the following
-// Then helper
-func (mmUpdate *mArticleRepositoryMockUpdate) When(ctx context.Context, m models.Article) *ArticleRepositoryMockUpdateExpectation {
-	if mmUpdate.mock.funcUpdate != nil {
-		mmUpdate.mock.t.Fatalf("ArticleRepositoryMock.Update mock is already set by Set")
-	}
-
-	expectation := &ArticleRepositoryMockUpdateExpectation{
-		mock:   mmUpdate.mock,
-		params: &ArticleRepositoryMockUpdateParams{ctx, m},
-	}
-	mmUpdate.expectations = append(mmUpdate.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleRepository.Update return parameters for the expectation previously defined by the When method
-func (e *ArticleRepositoryMockUpdateExpectation) Then(err error) *ArticleRepositoryMock {
-	e.results = &ArticleRepositoryMockUpdateResults{err}
-	return e.mock
-}
-
-// Update implements interfaces.ArticleRepository
-func (mmUpdate *ArticleRepositoryMock) Update(ctx context.Context, m models.Article) (err error) {
-	mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
-	defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
-
-	if mmUpdate.inspectFuncUpdate != nil {
-		mmUpdate.inspectFuncUpdate(ctx, m)
-	}
-
-	mm_params := &ArticleRepositoryMockUpdateParams{ctx, m}
-
-	// Record call args
-	mmUpdate.UpdateMock.mutex.Lock()
-	mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, mm_params)
-	mmUpdate.UpdateMock.mutex.Unlock()
-
-	for _, e := range mmUpdate.UpdateMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmUpdate.UpdateMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
-		mm_want := mmUpdate.UpdateMock.defaultExpectation.params
-		mm_got := ArticleRepositoryMockUpdateParams{ctx, m}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmUpdate.t.Errorf("ArticleRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmUpdate.UpdateMock.defaultExpectation.results
-		if mm_results == nil {
-			mmUpdate.t.Fatal("No results are set for the ArticleRepositoryMock.Update")
-		}
-		return (*mm_results).err
-	}
-	if mmUpdate.funcUpdate != nil {
-		return mmUpdate.funcUpdate(ctx, m)
-	}
-	mmUpdate.t.Fatalf("Unexpected call to ArticleRepositoryMock.Update. %v %v", ctx, m)
-	return
-}
-
-// UpdateAfterCounter returns a count of finished ArticleRepositoryMock.Update invocations
-func (mmUpdate *ArticleRepositoryMock) UpdateAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
-}
-
-// UpdateBeforeCounter returns a count of ArticleRepositoryMock.Update invocations
-func (mmUpdate *ArticleRepositoryMock) UpdateBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleRepositoryMock.Update.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmUpdate *mArticleRepositoryMockUpdate) Calls() []*ArticleRepositoryMockUpdateParams {
-	mmUpdate.mutex.RLock()
-
-	argCopy := make([]*ArticleRepositoryMockUpdateParams, len(mmUpdate.callArgs))
-	copy(argCopy, mmUpdate.callArgs)
-
-	mmUpdate.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockUpdateDone returns true if the count of the Update invocations corresponds
-// the number of defined expectations
-func (m *ArticleRepositoryMock) MinimockUpdateDone() bool {
-	for _, e := range m.UpdateMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockUpdateInspect logs each unmet expectation
-func (m *ArticleRepositoryMock) MinimockUpdateInspect() {
-	for _, e := range m.UpdateMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.Update with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
-		if m.UpdateMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleRepositoryMock.Update")
-		} else {
-			m.t.Errorf("Expected call to ArticleRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
-		m.t.Error("Expected call to ArticleRepositoryMock.Update")
-	}
-}
-
-// MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *ArticleRepositoryMock) MinimockFinish() {
-	if !m.minimockDone() {
-		m.MinimockAddInspect()
-
-		m.MinimockDeleteInspect()
-
-		m.MinimockGetAllInspect()
-
-		m.MinimockGetAllPreviewInspect()
-
-		m.MinimockGetByIDInspect()
-
-		m.MinimockGetByURLInspect()
-
-		m.MinimockGetPreviewByTagIDInspect()
-
-		m.MinimockUpdateInspect()
-		m.t.FailNow()
-	}
-}
-
-// MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *ArticleRepositoryMock) MinimockWait(timeout mm_time.Duration) {
-	timeoutCh := mm_time.After(timeout)
-	for {
-		if m.minimockDone() {
-			return
-		}
-		select {
-		case <-timeoutCh:
-			m.MinimockFinish()
-			return
-		case <-mm_time.After(10 * mm_time.Millisecond):
-		}
-	}
-}
-
-func (m *ArticleRepositoryMock) minimockDone() bool {
-	done := true
-	return done &&
-		m.MinimockAddDone() &&
-		m.MinimockDeleteDone() &&
-		m.MinimockGetAllDone() &&
-		m.MinimockGetAllPreviewDone() &&
-		m.MinimockGetByIDDone() &&
-		m.MinimockGetByURLDone() &&
-		m.MinimockGetPreviewByTagIDDone() &&
-		m.MinimockUpdateDone()
-}

+ 0 - 742
internal/repositories/mocks/article_tag_repository_minimock.go

@@ -1,742 +0,0 @@
-package mocks
-
-// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
-
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.ArticleTagRepository -o ./mocks/article_tag_repository_minimock.go -n ArticleTagRepositoryMock
-
-import (
-	"context"
-	"sync"
-	mm_atomic "sync/atomic"
-	mm_time "time"
-
-	"github.com/gojuno/minimock/v3"
-)
-
-// ArticleTagRepositoryMock implements interfaces.ArticleTagRepository
-type ArticleTagRepositoryMock struct {
-	t minimock.Tester
-
-	funcAdd          func(ctx context.Context, articleID int, tagIDs []int) (err error)
-	inspectFuncAdd   func(ctx context.Context, articleID int, tagIDs []int)
-	afterAddCounter  uint64
-	beforeAddCounter uint64
-	AddMock          mArticleTagRepositoryMockAdd
-
-	funcDelete          func(ctx context.Context, articleID int, tagIDs []int) (err error)
-	inspectFuncDelete   func(ctx context.Context, articleID int, tagIDs []int)
-	afterDeleteCounter  uint64
-	beforeDeleteCounter uint64
-	DeleteMock          mArticleTagRepositoryMockDelete
-
-	funcDeleteByArticleID          func(ctx context.Context, articleID int) (err error)
-	inspectFuncDeleteByArticleID   func(ctx context.Context, articleID int)
-	afterDeleteByArticleIDCounter  uint64
-	beforeDeleteByArticleIDCounter uint64
-	DeleteByArticleIDMock          mArticleTagRepositoryMockDeleteByArticleID
-}
-
-// NewArticleTagRepositoryMock returns a mock for interfaces.ArticleTagRepository
-func NewArticleTagRepositoryMock(t minimock.Tester) *ArticleTagRepositoryMock {
-	m := &ArticleTagRepositoryMock{t: t}
-	if controller, ok := t.(minimock.MockController); ok {
-		controller.RegisterMocker(m)
-	}
-
-	m.AddMock = mArticleTagRepositoryMockAdd{mock: m}
-	m.AddMock.callArgs = []*ArticleTagRepositoryMockAddParams{}
-
-	m.DeleteMock = mArticleTagRepositoryMockDelete{mock: m}
-	m.DeleteMock.callArgs = []*ArticleTagRepositoryMockDeleteParams{}
-
-	m.DeleteByArticleIDMock = mArticleTagRepositoryMockDeleteByArticleID{mock: m}
-	m.DeleteByArticleIDMock.callArgs = []*ArticleTagRepositoryMockDeleteByArticleIDParams{}
-
-	return m
-}
-
-type mArticleTagRepositoryMockAdd struct {
-	mock               *ArticleTagRepositoryMock
-	defaultExpectation *ArticleTagRepositoryMockAddExpectation
-	expectations       []*ArticleTagRepositoryMockAddExpectation
-
-	callArgs []*ArticleTagRepositoryMockAddParams
-	mutex    sync.RWMutex
-}
-
-// ArticleTagRepositoryMockAddExpectation specifies expectation struct of the ArticleTagRepository.Add
-type ArticleTagRepositoryMockAddExpectation struct {
-	mock    *ArticleTagRepositoryMock
-	params  *ArticleTagRepositoryMockAddParams
-	results *ArticleTagRepositoryMockAddResults
-	Counter uint64
-}
-
-// ArticleTagRepositoryMockAddParams contains parameters of the ArticleTagRepository.Add
-type ArticleTagRepositoryMockAddParams struct {
-	ctx       context.Context
-	articleID int
-	tagIDs    []int
-}
-
-// ArticleTagRepositoryMockAddResults contains results of the ArticleTagRepository.Add
-type ArticleTagRepositoryMockAddResults struct {
-	err error
-}
-
-// Expect sets up expected params for ArticleTagRepository.Add
-func (mmAdd *mArticleTagRepositoryMockAdd) Expect(ctx context.Context, articleID int, tagIDs []int) *mArticleTagRepositoryMockAdd {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("ArticleTagRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &ArticleTagRepositoryMockAddExpectation{}
-	}
-
-	mmAdd.defaultExpectation.params = &ArticleTagRepositoryMockAddParams{ctx, articleID, tagIDs}
-	for _, e := range mmAdd.expectations {
-		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
-			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
-		}
-	}
-
-	return mmAdd
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleTagRepository.Add
-func (mmAdd *mArticleTagRepositoryMockAdd) Inspect(f func(ctx context.Context, articleID int, tagIDs []int)) *mArticleTagRepositoryMockAdd {
-	if mmAdd.mock.inspectFuncAdd != nil {
-		mmAdd.mock.t.Fatalf("Inspect function is already set for ArticleTagRepositoryMock.Add")
-	}
-
-	mmAdd.mock.inspectFuncAdd = f
-
-	return mmAdd
-}
-
-// Return sets up results that will be returned by ArticleTagRepository.Add
-func (mmAdd *mArticleTagRepositoryMockAdd) Return(err error) *ArticleTagRepositoryMock {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("ArticleTagRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &ArticleTagRepositoryMockAddExpectation{mock: mmAdd.mock}
-	}
-	mmAdd.defaultExpectation.results = &ArticleTagRepositoryMockAddResults{err}
-	return mmAdd.mock
-}
-
-// Set uses given function f to mock the ArticleTagRepository.Add method
-func (mmAdd *mArticleTagRepositoryMockAdd) Set(f func(ctx context.Context, articleID int, tagIDs []int) (err error)) *ArticleTagRepositoryMock {
-	if mmAdd.defaultExpectation != nil {
-		mmAdd.mock.t.Fatalf("Default expectation is already set for the ArticleTagRepository.Add method")
-	}
-
-	if len(mmAdd.expectations) > 0 {
-		mmAdd.mock.t.Fatalf("Some expectations are already set for the ArticleTagRepository.Add method")
-	}
-
-	mmAdd.mock.funcAdd = f
-	return mmAdd.mock
-}
-
-// When sets expectation for the ArticleTagRepository.Add which will trigger the result defined by the following
-// Then helper
-func (mmAdd *mArticleTagRepositoryMockAdd) When(ctx context.Context, articleID int, tagIDs []int) *ArticleTagRepositoryMockAddExpectation {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("ArticleTagRepositoryMock.Add mock is already set by Set")
-	}
-
-	expectation := &ArticleTagRepositoryMockAddExpectation{
-		mock:   mmAdd.mock,
-		params: &ArticleTagRepositoryMockAddParams{ctx, articleID, tagIDs},
-	}
-	mmAdd.expectations = append(mmAdd.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleTagRepository.Add return parameters for the expectation previously defined by the When method
-func (e *ArticleTagRepositoryMockAddExpectation) Then(err error) *ArticleTagRepositoryMock {
-	e.results = &ArticleTagRepositoryMockAddResults{err}
-	return e.mock
-}
-
-// Add implements interfaces.ArticleTagRepository
-func (mmAdd *ArticleTagRepositoryMock) Add(ctx context.Context, articleID int, tagIDs []int) (err error) {
-	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
-	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
-
-	if mmAdd.inspectFuncAdd != nil {
-		mmAdd.inspectFuncAdd(ctx, articleID, tagIDs)
-	}
-
-	mm_params := &ArticleTagRepositoryMockAddParams{ctx, articleID, tagIDs}
-
-	// Record call args
-	mmAdd.AddMock.mutex.Lock()
-	mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params)
-	mmAdd.AddMock.mutex.Unlock()
-
-	for _, e := range mmAdd.AddMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmAdd.AddMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
-		mm_want := mmAdd.AddMock.defaultExpectation.params
-		mm_got := ArticleTagRepositoryMockAddParams{ctx, articleID, tagIDs}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmAdd.t.Errorf("ArticleTagRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmAdd.AddMock.defaultExpectation.results
-		if mm_results == nil {
-			mmAdd.t.Fatal("No results are set for the ArticleTagRepositoryMock.Add")
-		}
-		return (*mm_results).err
-	}
-	if mmAdd.funcAdd != nil {
-		return mmAdd.funcAdd(ctx, articleID, tagIDs)
-	}
-	mmAdd.t.Fatalf("Unexpected call to ArticleTagRepositoryMock.Add. %v %v %v", ctx, articleID, tagIDs)
-	return
-}
-
-// AddAfterCounter returns a count of finished ArticleTagRepositoryMock.Add invocations
-func (mmAdd *ArticleTagRepositoryMock) AddAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
-}
-
-// AddBeforeCounter returns a count of ArticleTagRepositoryMock.Add invocations
-func (mmAdd *ArticleTagRepositoryMock) AddBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleTagRepositoryMock.Add.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmAdd *mArticleTagRepositoryMockAdd) Calls() []*ArticleTagRepositoryMockAddParams {
-	mmAdd.mutex.RLock()
-
-	argCopy := make([]*ArticleTagRepositoryMockAddParams, len(mmAdd.callArgs))
-	copy(argCopy, mmAdd.callArgs)
-
-	mmAdd.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockAddDone returns true if the count of the Add invocations corresponds
-// the number of defined expectations
-func (m *ArticleTagRepositoryMock) MinimockAddDone() bool {
-	for _, e := range m.AddMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockAddInspect logs each unmet expectation
-func (m *ArticleTagRepositoryMock) MinimockAddInspect() {
-	for _, e := range m.AddMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleTagRepositoryMock.Add with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		if m.AddMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleTagRepositoryMock.Add")
-		} else {
-			m.t.Errorf("Expected call to ArticleTagRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		m.t.Error("Expected call to ArticleTagRepositoryMock.Add")
-	}
-}
-
-type mArticleTagRepositoryMockDelete struct {
-	mock               *ArticleTagRepositoryMock
-	defaultExpectation *ArticleTagRepositoryMockDeleteExpectation
-	expectations       []*ArticleTagRepositoryMockDeleteExpectation
-
-	callArgs []*ArticleTagRepositoryMockDeleteParams
-	mutex    sync.RWMutex
-}
-
-// ArticleTagRepositoryMockDeleteExpectation specifies expectation struct of the ArticleTagRepository.Delete
-type ArticleTagRepositoryMockDeleteExpectation struct {
-	mock    *ArticleTagRepositoryMock
-	params  *ArticleTagRepositoryMockDeleteParams
-	results *ArticleTagRepositoryMockDeleteResults
-	Counter uint64
-}
-
-// ArticleTagRepositoryMockDeleteParams contains parameters of the ArticleTagRepository.Delete
-type ArticleTagRepositoryMockDeleteParams struct {
-	ctx       context.Context
-	articleID int
-	tagIDs    []int
-}
-
-// ArticleTagRepositoryMockDeleteResults contains results of the ArticleTagRepository.Delete
-type ArticleTagRepositoryMockDeleteResults struct {
-	err error
-}
-
-// Expect sets up expected params for ArticleTagRepository.Delete
-func (mmDelete *mArticleTagRepositoryMockDelete) Expect(ctx context.Context, articleID int, tagIDs []int) *mArticleTagRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ArticleTagRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ArticleTagRepositoryMockDeleteExpectation{}
-	}
-
-	mmDelete.defaultExpectation.params = &ArticleTagRepositoryMockDeleteParams{ctx, articleID, tagIDs}
-	for _, e := range mmDelete.expectations {
-		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
-			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
-		}
-	}
-
-	return mmDelete
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleTagRepository.Delete
-func (mmDelete *mArticleTagRepositoryMockDelete) Inspect(f func(ctx context.Context, articleID int, tagIDs []int)) *mArticleTagRepositoryMockDelete {
-	if mmDelete.mock.inspectFuncDelete != nil {
-		mmDelete.mock.t.Fatalf("Inspect function is already set for ArticleTagRepositoryMock.Delete")
-	}
-
-	mmDelete.mock.inspectFuncDelete = f
-
-	return mmDelete
-}
-
-// Return sets up results that will be returned by ArticleTagRepository.Delete
-func (mmDelete *mArticleTagRepositoryMockDelete) Return(err error) *ArticleTagRepositoryMock {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ArticleTagRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &ArticleTagRepositoryMockDeleteExpectation{mock: mmDelete.mock}
-	}
-	mmDelete.defaultExpectation.results = &ArticleTagRepositoryMockDeleteResults{err}
-	return mmDelete.mock
-}
-
-// Set uses given function f to mock the ArticleTagRepository.Delete method
-func (mmDelete *mArticleTagRepositoryMockDelete) Set(f func(ctx context.Context, articleID int, tagIDs []int) (err error)) *ArticleTagRepositoryMock {
-	if mmDelete.defaultExpectation != nil {
-		mmDelete.mock.t.Fatalf("Default expectation is already set for the ArticleTagRepository.Delete method")
-	}
-
-	if len(mmDelete.expectations) > 0 {
-		mmDelete.mock.t.Fatalf("Some expectations are already set for the ArticleTagRepository.Delete method")
-	}
-
-	mmDelete.mock.funcDelete = f
-	return mmDelete.mock
-}
-
-// When sets expectation for the ArticleTagRepository.Delete which will trigger the result defined by the following
-// Then helper
-func (mmDelete *mArticleTagRepositoryMockDelete) When(ctx context.Context, articleID int, tagIDs []int) *ArticleTagRepositoryMockDeleteExpectation {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("ArticleTagRepositoryMock.Delete mock is already set by Set")
-	}
-
-	expectation := &ArticleTagRepositoryMockDeleteExpectation{
-		mock:   mmDelete.mock,
-		params: &ArticleTagRepositoryMockDeleteParams{ctx, articleID, tagIDs},
-	}
-	mmDelete.expectations = append(mmDelete.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleTagRepository.Delete return parameters for the expectation previously defined by the When method
-func (e *ArticleTagRepositoryMockDeleteExpectation) Then(err error) *ArticleTagRepositoryMock {
-	e.results = &ArticleTagRepositoryMockDeleteResults{err}
-	return e.mock
-}
-
-// Delete implements interfaces.ArticleTagRepository
-func (mmDelete *ArticleTagRepositoryMock) Delete(ctx context.Context, articleID int, tagIDs []int) (err error) {
-	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
-	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
-
-	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, articleID, tagIDs)
-	}
-
-	mm_params := &ArticleTagRepositoryMockDeleteParams{ctx, articleID, tagIDs}
-
-	// Record call args
-	mmDelete.DeleteMock.mutex.Lock()
-	mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, mm_params)
-	mmDelete.DeleteMock.mutex.Unlock()
-
-	for _, e := range mmDelete.DeleteMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmDelete.DeleteMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
-		mm_want := mmDelete.DeleteMock.defaultExpectation.params
-		mm_got := ArticleTagRepositoryMockDeleteParams{ctx, articleID, tagIDs}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmDelete.t.Errorf("ArticleTagRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmDelete.DeleteMock.defaultExpectation.results
-		if mm_results == nil {
-			mmDelete.t.Fatal("No results are set for the ArticleTagRepositoryMock.Delete")
-		}
-		return (*mm_results).err
-	}
-	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, articleID, tagIDs)
-	}
-	mmDelete.t.Fatalf("Unexpected call to ArticleTagRepositoryMock.Delete. %v %v %v", ctx, articleID, tagIDs)
-	return
-}
-
-// DeleteAfterCounter returns a count of finished ArticleTagRepositoryMock.Delete invocations
-func (mmDelete *ArticleTagRepositoryMock) DeleteAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
-}
-
-// DeleteBeforeCounter returns a count of ArticleTagRepositoryMock.Delete invocations
-func (mmDelete *ArticleTagRepositoryMock) DeleteBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleTagRepositoryMock.Delete.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmDelete *mArticleTagRepositoryMockDelete) Calls() []*ArticleTagRepositoryMockDeleteParams {
-	mmDelete.mutex.RLock()
-
-	argCopy := make([]*ArticleTagRepositoryMockDeleteParams, len(mmDelete.callArgs))
-	copy(argCopy, mmDelete.callArgs)
-
-	mmDelete.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockDeleteDone returns true if the count of the Delete invocations corresponds
-// the number of defined expectations
-func (m *ArticleTagRepositoryMock) MinimockDeleteDone() bool {
-	for _, e := range m.DeleteMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockDeleteInspect logs each unmet expectation
-func (m *ArticleTagRepositoryMock) MinimockDeleteInspect() {
-	for _, e := range m.DeleteMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleTagRepositoryMock.Delete with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		if m.DeleteMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleTagRepositoryMock.Delete")
-		} else {
-			m.t.Errorf("Expected call to ArticleTagRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		m.t.Error("Expected call to ArticleTagRepositoryMock.Delete")
-	}
-}
-
-type mArticleTagRepositoryMockDeleteByArticleID struct {
-	mock               *ArticleTagRepositoryMock
-	defaultExpectation *ArticleTagRepositoryMockDeleteByArticleIDExpectation
-	expectations       []*ArticleTagRepositoryMockDeleteByArticleIDExpectation
-
-	callArgs []*ArticleTagRepositoryMockDeleteByArticleIDParams
-	mutex    sync.RWMutex
-}
-
-// ArticleTagRepositoryMockDeleteByArticleIDExpectation specifies expectation struct of the ArticleTagRepository.DeleteByArticleID
-type ArticleTagRepositoryMockDeleteByArticleIDExpectation struct {
-	mock    *ArticleTagRepositoryMock
-	params  *ArticleTagRepositoryMockDeleteByArticleIDParams
-	results *ArticleTagRepositoryMockDeleteByArticleIDResults
-	Counter uint64
-}
-
-// ArticleTagRepositoryMockDeleteByArticleIDParams contains parameters of the ArticleTagRepository.DeleteByArticleID
-type ArticleTagRepositoryMockDeleteByArticleIDParams struct {
-	ctx       context.Context
-	articleID int
-}
-
-// ArticleTagRepositoryMockDeleteByArticleIDResults contains results of the ArticleTagRepository.DeleteByArticleID
-type ArticleTagRepositoryMockDeleteByArticleIDResults struct {
-	err error
-}
-
-// Expect sets up expected params for ArticleTagRepository.DeleteByArticleID
-func (mmDeleteByArticleID *mArticleTagRepositoryMockDeleteByArticleID) Expect(ctx context.Context, articleID int) *mArticleTagRepositoryMockDeleteByArticleID {
-	if mmDeleteByArticleID.mock.funcDeleteByArticleID != nil {
-		mmDeleteByArticleID.mock.t.Fatalf("ArticleTagRepositoryMock.DeleteByArticleID mock is already set by Set")
-	}
-
-	if mmDeleteByArticleID.defaultExpectation == nil {
-		mmDeleteByArticleID.defaultExpectation = &ArticleTagRepositoryMockDeleteByArticleIDExpectation{}
-	}
-
-	mmDeleteByArticleID.defaultExpectation.params = &ArticleTagRepositoryMockDeleteByArticleIDParams{ctx, articleID}
-	for _, e := range mmDeleteByArticleID.expectations {
-		if minimock.Equal(e.params, mmDeleteByArticleID.defaultExpectation.params) {
-			mmDeleteByArticleID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteByArticleID.defaultExpectation.params)
-		}
-	}
-
-	return mmDeleteByArticleID
-}
-
-// Inspect accepts an inspector function that has same arguments as the ArticleTagRepository.DeleteByArticleID
-func (mmDeleteByArticleID *mArticleTagRepositoryMockDeleteByArticleID) Inspect(f func(ctx context.Context, articleID int)) *mArticleTagRepositoryMockDeleteByArticleID {
-	if mmDeleteByArticleID.mock.inspectFuncDeleteByArticleID != nil {
-		mmDeleteByArticleID.mock.t.Fatalf("Inspect function is already set for ArticleTagRepositoryMock.DeleteByArticleID")
-	}
-
-	mmDeleteByArticleID.mock.inspectFuncDeleteByArticleID = f
-
-	return mmDeleteByArticleID
-}
-
-// Return sets up results that will be returned by ArticleTagRepository.DeleteByArticleID
-func (mmDeleteByArticleID *mArticleTagRepositoryMockDeleteByArticleID) Return(err error) *ArticleTagRepositoryMock {
-	if mmDeleteByArticleID.mock.funcDeleteByArticleID != nil {
-		mmDeleteByArticleID.mock.t.Fatalf("ArticleTagRepositoryMock.DeleteByArticleID mock is already set by Set")
-	}
-
-	if mmDeleteByArticleID.defaultExpectation == nil {
-		mmDeleteByArticleID.defaultExpectation = &ArticleTagRepositoryMockDeleteByArticleIDExpectation{mock: mmDeleteByArticleID.mock}
-	}
-	mmDeleteByArticleID.defaultExpectation.results = &ArticleTagRepositoryMockDeleteByArticleIDResults{err}
-	return mmDeleteByArticleID.mock
-}
-
-// Set uses given function f to mock the ArticleTagRepository.DeleteByArticleID method
-func (mmDeleteByArticleID *mArticleTagRepositoryMockDeleteByArticleID) Set(f func(ctx context.Context, articleID int) (err error)) *ArticleTagRepositoryMock {
-	if mmDeleteByArticleID.defaultExpectation != nil {
-		mmDeleteByArticleID.mock.t.Fatalf("Default expectation is already set for the ArticleTagRepository.DeleteByArticleID method")
-	}
-
-	if len(mmDeleteByArticleID.expectations) > 0 {
-		mmDeleteByArticleID.mock.t.Fatalf("Some expectations are already set for the ArticleTagRepository.DeleteByArticleID method")
-	}
-
-	mmDeleteByArticleID.mock.funcDeleteByArticleID = f
-	return mmDeleteByArticleID.mock
-}
-
-// When sets expectation for the ArticleTagRepository.DeleteByArticleID which will trigger the result defined by the following
-// Then helper
-func (mmDeleteByArticleID *mArticleTagRepositoryMockDeleteByArticleID) When(ctx context.Context, articleID int) *ArticleTagRepositoryMockDeleteByArticleIDExpectation {
-	if mmDeleteByArticleID.mock.funcDeleteByArticleID != nil {
-		mmDeleteByArticleID.mock.t.Fatalf("ArticleTagRepositoryMock.DeleteByArticleID mock is already set by Set")
-	}
-
-	expectation := &ArticleTagRepositoryMockDeleteByArticleIDExpectation{
-		mock:   mmDeleteByArticleID.mock,
-		params: &ArticleTagRepositoryMockDeleteByArticleIDParams{ctx, articleID},
-	}
-	mmDeleteByArticleID.expectations = append(mmDeleteByArticleID.expectations, expectation)
-	return expectation
-}
-
-// Then sets up ArticleTagRepository.DeleteByArticleID return parameters for the expectation previously defined by the When method
-func (e *ArticleTagRepositoryMockDeleteByArticleIDExpectation) Then(err error) *ArticleTagRepositoryMock {
-	e.results = &ArticleTagRepositoryMockDeleteByArticleIDResults{err}
-	return e.mock
-}
-
-// DeleteByArticleID implements interfaces.ArticleTagRepository
-func (mmDeleteByArticleID *ArticleTagRepositoryMock) DeleteByArticleID(ctx context.Context, articleID int) (err error) {
-	mm_atomic.AddUint64(&mmDeleteByArticleID.beforeDeleteByArticleIDCounter, 1)
-	defer mm_atomic.AddUint64(&mmDeleteByArticleID.afterDeleteByArticleIDCounter, 1)
-
-	if mmDeleteByArticleID.inspectFuncDeleteByArticleID != nil {
-		mmDeleteByArticleID.inspectFuncDeleteByArticleID(ctx, articleID)
-	}
-
-	mm_params := &ArticleTagRepositoryMockDeleteByArticleIDParams{ctx, articleID}
-
-	// Record call args
-	mmDeleteByArticleID.DeleteByArticleIDMock.mutex.Lock()
-	mmDeleteByArticleID.DeleteByArticleIDMock.callArgs = append(mmDeleteByArticleID.DeleteByArticleIDMock.callArgs, mm_params)
-	mmDeleteByArticleID.DeleteByArticleIDMock.mutex.Unlock()
-
-	for _, e := range mmDeleteByArticleID.DeleteByArticleIDMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmDeleteByArticleID.DeleteByArticleIDMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmDeleteByArticleID.DeleteByArticleIDMock.defaultExpectation.Counter, 1)
-		mm_want := mmDeleteByArticleID.DeleteByArticleIDMock.defaultExpectation.params
-		mm_got := ArticleTagRepositoryMockDeleteByArticleIDParams{ctx, articleID}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmDeleteByArticleID.t.Errorf("ArticleTagRepositoryMock.DeleteByArticleID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmDeleteByArticleID.DeleteByArticleIDMock.defaultExpectation.results
-		if mm_results == nil {
-			mmDeleteByArticleID.t.Fatal("No results are set for the ArticleTagRepositoryMock.DeleteByArticleID")
-		}
-		return (*mm_results).err
-	}
-	if mmDeleteByArticleID.funcDeleteByArticleID != nil {
-		return mmDeleteByArticleID.funcDeleteByArticleID(ctx, articleID)
-	}
-	mmDeleteByArticleID.t.Fatalf("Unexpected call to ArticleTagRepositoryMock.DeleteByArticleID. %v %v", ctx, articleID)
-	return
-}
-
-// DeleteByArticleIDAfterCounter returns a count of finished ArticleTagRepositoryMock.DeleteByArticleID invocations
-func (mmDeleteByArticleID *ArticleTagRepositoryMock) DeleteByArticleIDAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmDeleteByArticleID.afterDeleteByArticleIDCounter)
-}
-
-// DeleteByArticleIDBeforeCounter returns a count of ArticleTagRepositoryMock.DeleteByArticleID invocations
-func (mmDeleteByArticleID *ArticleTagRepositoryMock) DeleteByArticleIDBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmDeleteByArticleID.beforeDeleteByArticleIDCounter)
-}
-
-// Calls returns a list of arguments used in each call to ArticleTagRepositoryMock.DeleteByArticleID.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmDeleteByArticleID *mArticleTagRepositoryMockDeleteByArticleID) Calls() []*ArticleTagRepositoryMockDeleteByArticleIDParams {
-	mmDeleteByArticleID.mutex.RLock()
-
-	argCopy := make([]*ArticleTagRepositoryMockDeleteByArticleIDParams, len(mmDeleteByArticleID.callArgs))
-	copy(argCopy, mmDeleteByArticleID.callArgs)
-
-	mmDeleteByArticleID.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockDeleteByArticleIDDone returns true if the count of the DeleteByArticleID invocations corresponds
-// the number of defined expectations
-func (m *ArticleTagRepositoryMock) MinimockDeleteByArticleIDDone() bool {
-	for _, e := range m.DeleteByArticleIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.DeleteByArticleIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteByArticleIDCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcDeleteByArticleID != nil && mm_atomic.LoadUint64(&m.afterDeleteByArticleIDCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockDeleteByArticleIDInspect logs each unmet expectation
-func (m *ArticleTagRepositoryMock) MinimockDeleteByArticleIDInspect() {
-	for _, e := range m.DeleteByArticleIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ArticleTagRepositoryMock.DeleteByArticleID with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.DeleteByArticleIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteByArticleIDCounter) < 1 {
-		if m.DeleteByArticleIDMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ArticleTagRepositoryMock.DeleteByArticleID")
-		} else {
-			m.t.Errorf("Expected call to ArticleTagRepositoryMock.DeleteByArticleID with params: %#v", *m.DeleteByArticleIDMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcDeleteByArticleID != nil && mm_atomic.LoadUint64(&m.afterDeleteByArticleIDCounter) < 1 {
-		m.t.Error("Expected call to ArticleTagRepositoryMock.DeleteByArticleID")
-	}
-}
-
-// MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *ArticleTagRepositoryMock) MinimockFinish() {
-	if !m.minimockDone() {
-		m.MinimockAddInspect()
-
-		m.MinimockDeleteInspect()
-
-		m.MinimockDeleteByArticleIDInspect()
-		m.t.FailNow()
-	}
-}
-
-// MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *ArticleTagRepositoryMock) MinimockWait(timeout mm_time.Duration) {
-	timeoutCh := mm_time.After(timeout)
-	for {
-		if m.minimockDone() {
-			return
-		}
-		select {
-		case <-timeoutCh:
-			m.MinimockFinish()
-			return
-		case <-mm_time.After(10 * mm_time.Millisecond):
-		}
-	}
-}
-
-func (m *ArticleTagRepositoryMock) minimockDone() bool {
-	done := true
-	return done &&
-		m.MinimockAddDone() &&
-		m.MinimockDeleteDone() &&
-		m.MinimockDeleteByArticleIDDone()
-}

+ 0 - 2113
internal/repositories/mocks/tag_repository_minimock.go

@@ -1,2113 +0,0 @@
-package mocks
-
-// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
-
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.TagRepository -o ./mocks/tag_repository_minimock.go -n TagRepositoryMock
-
-import (
-	"context"
-	"sync"
-	mm_atomic "sync/atomic"
-	mm_time "time"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	"github.com/gojuno/minimock/v3"
-)
-
-// TagRepositoryMock implements interfaces.TagRepository
-type TagRepositoryMock struct {
-	t minimock.Tester
-
-	funcAdd          func(ctx context.Context, m models.Tag) (err error)
-	inspectFuncAdd   func(ctx context.Context, m models.Tag)
-	afterAddCounter  uint64
-	beforeAddCounter uint64
-	AddMock          mTagRepositoryMockAdd
-
-	funcDelete          func(ctx context.Context, ID int) (err error)
-	inspectFuncDelete   func(ctx context.Context, ID int)
-	afterDeleteCounter  uint64
-	beforeDeleteCounter uint64
-	DeleteMock          mTagRepositoryMockDelete
-
-	funcGetAll          func(ctx context.Context) (ta1 []models.Tag, err error)
-	inspectFuncGetAll   func(ctx context.Context)
-	afterGetAllCounter  uint64
-	beforeGetAllCounter uint64
-	GetAllMock          mTagRepositoryMockGetAll
-
-	funcGetAllUsed          func(ctx context.Context) (ta1 []models.Tag, err error)
-	inspectFuncGetAllUsed   func(ctx context.Context)
-	afterGetAllUsedCounter  uint64
-	beforeGetAllUsedCounter uint64
-	GetAllUsedMock          mTagRepositoryMockGetAllUsed
-
-	funcGetByArticleID          func(ctx context.Context, ID int) (ta1 []models.Tag, err error)
-	inspectFuncGetByArticleID   func(ctx context.Context, ID int)
-	afterGetByArticleIDCounter  uint64
-	beforeGetByArticleIDCounter uint64
-	GetByArticleIDMock          mTagRepositoryMockGetByArticleID
-
-	funcGetByID          func(ctx context.Context, ID int) (tp1 *models.Tag, err error)
-	inspectFuncGetByID   func(ctx context.Context, ID int)
-	afterGetByIDCounter  uint64
-	beforeGetByIDCounter uint64
-	GetByIDMock          mTagRepositoryMockGetByID
-
-	funcGetByURL          func(ctx context.Context, tag string) (tp1 *models.Tag, err error)
-	inspectFuncGetByURL   func(ctx context.Context, tag string)
-	afterGetByURLCounter  uint64
-	beforeGetByURLCounter uint64
-	GetByURLMock          mTagRepositoryMockGetByURL
-
-	funcIsUsed          func(ctx context.Context, ID int) (b1 bool, err error)
-	inspectFuncIsUsed   func(ctx context.Context, ID int)
-	afterIsUsedCounter  uint64
-	beforeIsUsedCounter uint64
-	IsUsedMock          mTagRepositoryMockIsUsed
-
-	funcUpdate          func(ctx context.Context, m models.Tag) (err error)
-	inspectFuncUpdate   func(ctx context.Context, m models.Tag)
-	afterUpdateCounter  uint64
-	beforeUpdateCounter uint64
-	UpdateMock          mTagRepositoryMockUpdate
-}
-
-// NewTagRepositoryMock returns a mock for interfaces.TagRepository
-func NewTagRepositoryMock(t minimock.Tester) *TagRepositoryMock {
-	m := &TagRepositoryMock{t: t}
-	if controller, ok := t.(minimock.MockController); ok {
-		controller.RegisterMocker(m)
-	}
-
-	m.AddMock = mTagRepositoryMockAdd{mock: m}
-	m.AddMock.callArgs = []*TagRepositoryMockAddParams{}
-
-	m.DeleteMock = mTagRepositoryMockDelete{mock: m}
-	m.DeleteMock.callArgs = []*TagRepositoryMockDeleteParams{}
-
-	m.GetAllMock = mTagRepositoryMockGetAll{mock: m}
-	m.GetAllMock.callArgs = []*TagRepositoryMockGetAllParams{}
-
-	m.GetAllUsedMock = mTagRepositoryMockGetAllUsed{mock: m}
-	m.GetAllUsedMock.callArgs = []*TagRepositoryMockGetAllUsedParams{}
-
-	m.GetByArticleIDMock = mTagRepositoryMockGetByArticleID{mock: m}
-	m.GetByArticleIDMock.callArgs = []*TagRepositoryMockGetByArticleIDParams{}
-
-	m.GetByIDMock = mTagRepositoryMockGetByID{mock: m}
-	m.GetByIDMock.callArgs = []*TagRepositoryMockGetByIDParams{}
-
-	m.GetByURLMock = mTagRepositoryMockGetByURL{mock: m}
-	m.GetByURLMock.callArgs = []*TagRepositoryMockGetByURLParams{}
-
-	m.IsUsedMock = mTagRepositoryMockIsUsed{mock: m}
-	m.IsUsedMock.callArgs = []*TagRepositoryMockIsUsedParams{}
-
-	m.UpdateMock = mTagRepositoryMockUpdate{mock: m}
-	m.UpdateMock.callArgs = []*TagRepositoryMockUpdateParams{}
-
-	return m
-}
-
-type mTagRepositoryMockAdd struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockAddExpectation
-	expectations       []*TagRepositoryMockAddExpectation
-
-	callArgs []*TagRepositoryMockAddParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockAddExpectation specifies expectation struct of the TagRepository.Add
-type TagRepositoryMockAddExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockAddParams
-	results *TagRepositoryMockAddResults
-	Counter uint64
-}
-
-// TagRepositoryMockAddParams contains parameters of the TagRepository.Add
-type TagRepositoryMockAddParams struct {
-	ctx context.Context
-	m   models.Tag
-}
-
-// TagRepositoryMockAddResults contains results of the TagRepository.Add
-type TagRepositoryMockAddResults struct {
-	err error
-}
-
-// Expect sets up expected params for TagRepository.Add
-func (mmAdd *mTagRepositoryMockAdd) Expect(ctx context.Context, m models.Tag) *mTagRepositoryMockAdd {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &TagRepositoryMockAddExpectation{}
-	}
-
-	mmAdd.defaultExpectation.params = &TagRepositoryMockAddParams{ctx, m}
-	for _, e := range mmAdd.expectations {
-		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
-			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
-		}
-	}
-
-	return mmAdd
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.Add
-func (mmAdd *mTagRepositoryMockAdd) Inspect(f func(ctx context.Context, m models.Tag)) *mTagRepositoryMockAdd {
-	if mmAdd.mock.inspectFuncAdd != nil {
-		mmAdd.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.Add")
-	}
-
-	mmAdd.mock.inspectFuncAdd = f
-
-	return mmAdd
-}
-
-// Return sets up results that will be returned by TagRepository.Add
-func (mmAdd *mTagRepositoryMockAdd) Return(err error) *TagRepositoryMock {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &TagRepositoryMockAddExpectation{mock: mmAdd.mock}
-	}
-	mmAdd.defaultExpectation.results = &TagRepositoryMockAddResults{err}
-	return mmAdd.mock
-}
-
-// Set uses given function f to mock the TagRepository.Add method
-func (mmAdd *mTagRepositoryMockAdd) Set(f func(ctx context.Context, m models.Tag) (err error)) *TagRepositoryMock {
-	if mmAdd.defaultExpectation != nil {
-		mmAdd.mock.t.Fatalf("Default expectation is already set for the TagRepository.Add method")
-	}
-
-	if len(mmAdd.expectations) > 0 {
-		mmAdd.mock.t.Fatalf("Some expectations are already set for the TagRepository.Add method")
-	}
-
-	mmAdd.mock.funcAdd = f
-	return mmAdd.mock
-}
-
-// When sets expectation for the TagRepository.Add which will trigger the result defined by the following
-// Then helper
-func (mmAdd *mTagRepositoryMockAdd) When(ctx context.Context, m models.Tag) *TagRepositoryMockAddExpectation {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("TagRepositoryMock.Add mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockAddExpectation{
-		mock:   mmAdd.mock,
-		params: &TagRepositoryMockAddParams{ctx, m},
-	}
-	mmAdd.expectations = append(mmAdd.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.Add return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockAddExpectation) Then(err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockAddResults{err}
-	return e.mock
-}
-
-// Add implements interfaces.TagRepository
-func (mmAdd *TagRepositoryMock) Add(ctx context.Context, m models.Tag) (err error) {
-	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
-	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
-
-	if mmAdd.inspectFuncAdd != nil {
-		mmAdd.inspectFuncAdd(ctx, m)
-	}
-
-	mm_params := &TagRepositoryMockAddParams{ctx, m}
-
-	// Record call args
-	mmAdd.AddMock.mutex.Lock()
-	mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params)
-	mmAdd.AddMock.mutex.Unlock()
-
-	for _, e := range mmAdd.AddMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmAdd.AddMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
-		mm_want := mmAdd.AddMock.defaultExpectation.params
-		mm_got := TagRepositoryMockAddParams{ctx, m}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmAdd.t.Errorf("TagRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmAdd.AddMock.defaultExpectation.results
-		if mm_results == nil {
-			mmAdd.t.Fatal("No results are set for the TagRepositoryMock.Add")
-		}
-		return (*mm_results).err
-	}
-	if mmAdd.funcAdd != nil {
-		return mmAdd.funcAdd(ctx, m)
-	}
-	mmAdd.t.Fatalf("Unexpected call to TagRepositoryMock.Add. %v %v", ctx, m)
-	return
-}
-
-// AddAfterCounter returns a count of finished TagRepositoryMock.Add invocations
-func (mmAdd *TagRepositoryMock) AddAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
-}
-
-// AddBeforeCounter returns a count of TagRepositoryMock.Add invocations
-func (mmAdd *TagRepositoryMock) AddBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.Add.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmAdd *mTagRepositoryMockAdd) Calls() []*TagRepositoryMockAddParams {
-	mmAdd.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockAddParams, len(mmAdd.callArgs))
-	copy(argCopy, mmAdd.callArgs)
-
-	mmAdd.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockAddDone returns true if the count of the Add invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockAddDone() bool {
-	for _, e := range m.AddMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockAddInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockAddInspect() {
-	for _, e := range m.AddMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.Add with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		if m.AddMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.Add")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.Add")
-	}
-}
-
-type mTagRepositoryMockDelete struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockDeleteExpectation
-	expectations       []*TagRepositoryMockDeleteExpectation
-
-	callArgs []*TagRepositoryMockDeleteParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockDeleteExpectation specifies expectation struct of the TagRepository.Delete
-type TagRepositoryMockDeleteExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockDeleteParams
-	results *TagRepositoryMockDeleteResults
-	Counter uint64
-}
-
-// TagRepositoryMockDeleteParams contains parameters of the TagRepository.Delete
-type TagRepositoryMockDeleteParams struct {
-	ctx context.Context
-	ID  int
-}
-
-// TagRepositoryMockDeleteResults contains results of the TagRepository.Delete
-type TagRepositoryMockDeleteResults struct {
-	err error
-}
-
-// Expect sets up expected params for TagRepository.Delete
-func (mmDelete *mTagRepositoryMockDelete) Expect(ctx context.Context, ID int) *mTagRepositoryMockDelete {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &TagRepositoryMockDeleteExpectation{}
-	}
-
-	mmDelete.defaultExpectation.params = &TagRepositoryMockDeleteParams{ctx, ID}
-	for _, e := range mmDelete.expectations {
-		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
-			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
-		}
-	}
-
-	return mmDelete
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.Delete
-func (mmDelete *mTagRepositoryMockDelete) Inspect(f func(ctx context.Context, ID int)) *mTagRepositoryMockDelete {
-	if mmDelete.mock.inspectFuncDelete != nil {
-		mmDelete.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.Delete")
-	}
-
-	mmDelete.mock.inspectFuncDelete = f
-
-	return mmDelete
-}
-
-// Return sets up results that will be returned by TagRepository.Delete
-func (mmDelete *mTagRepositoryMockDelete) Return(err error) *TagRepositoryMock {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Set")
-	}
-
-	if mmDelete.defaultExpectation == nil {
-		mmDelete.defaultExpectation = &TagRepositoryMockDeleteExpectation{mock: mmDelete.mock}
-	}
-	mmDelete.defaultExpectation.results = &TagRepositoryMockDeleteResults{err}
-	return mmDelete.mock
-}
-
-// Set uses given function f to mock the TagRepository.Delete method
-func (mmDelete *mTagRepositoryMockDelete) Set(f func(ctx context.Context, ID int) (err error)) *TagRepositoryMock {
-	if mmDelete.defaultExpectation != nil {
-		mmDelete.mock.t.Fatalf("Default expectation is already set for the TagRepository.Delete method")
-	}
-
-	if len(mmDelete.expectations) > 0 {
-		mmDelete.mock.t.Fatalf("Some expectations are already set for the TagRepository.Delete method")
-	}
-
-	mmDelete.mock.funcDelete = f
-	return mmDelete.mock
-}
-
-// When sets expectation for the TagRepository.Delete which will trigger the result defined by the following
-// Then helper
-func (mmDelete *mTagRepositoryMockDelete) When(ctx context.Context, ID int) *TagRepositoryMockDeleteExpectation {
-	if mmDelete.mock.funcDelete != nil {
-		mmDelete.mock.t.Fatalf("TagRepositoryMock.Delete mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockDeleteExpectation{
-		mock:   mmDelete.mock,
-		params: &TagRepositoryMockDeleteParams{ctx, ID},
-	}
-	mmDelete.expectations = append(mmDelete.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.Delete return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockDeleteExpectation) Then(err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockDeleteResults{err}
-	return e.mock
-}
-
-// Delete implements interfaces.TagRepository
-func (mmDelete *TagRepositoryMock) Delete(ctx context.Context, ID int) (err error) {
-	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
-	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)
-
-	if mmDelete.inspectFuncDelete != nil {
-		mmDelete.inspectFuncDelete(ctx, ID)
-	}
-
-	mm_params := &TagRepositoryMockDeleteParams{ctx, ID}
-
-	// Record call args
-	mmDelete.DeleteMock.mutex.Lock()
-	mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, mm_params)
-	mmDelete.DeleteMock.mutex.Unlock()
-
-	for _, e := range mmDelete.DeleteMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmDelete.DeleteMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
-		mm_want := mmDelete.DeleteMock.defaultExpectation.params
-		mm_got := TagRepositoryMockDeleteParams{ctx, ID}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmDelete.t.Errorf("TagRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmDelete.DeleteMock.defaultExpectation.results
-		if mm_results == nil {
-			mmDelete.t.Fatal("No results are set for the TagRepositoryMock.Delete")
-		}
-		return (*mm_results).err
-	}
-	if mmDelete.funcDelete != nil {
-		return mmDelete.funcDelete(ctx, ID)
-	}
-	mmDelete.t.Fatalf("Unexpected call to TagRepositoryMock.Delete. %v %v", ctx, ID)
-	return
-}
-
-// DeleteAfterCounter returns a count of finished TagRepositoryMock.Delete invocations
-func (mmDelete *TagRepositoryMock) DeleteAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
-}
-
-// DeleteBeforeCounter returns a count of TagRepositoryMock.Delete invocations
-func (mmDelete *TagRepositoryMock) DeleteBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.Delete.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmDelete *mTagRepositoryMockDelete) Calls() []*TagRepositoryMockDeleteParams {
-	mmDelete.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockDeleteParams, len(mmDelete.callArgs))
-	copy(argCopy, mmDelete.callArgs)
-
-	mmDelete.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockDeleteDone returns true if the count of the Delete invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockDeleteDone() bool {
-	for _, e := range m.DeleteMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockDeleteInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockDeleteInspect() {
-	for _, e := range m.DeleteMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.Delete with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.DeleteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		if m.DeleteMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.Delete")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcDelete != nil && mm_atomic.LoadUint64(&m.afterDeleteCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.Delete")
-	}
-}
-
-type mTagRepositoryMockGetAll struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockGetAllExpectation
-	expectations       []*TagRepositoryMockGetAllExpectation
-
-	callArgs []*TagRepositoryMockGetAllParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockGetAllExpectation specifies expectation struct of the TagRepository.GetAll
-type TagRepositoryMockGetAllExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockGetAllParams
-	results *TagRepositoryMockGetAllResults
-	Counter uint64
-}
-
-// TagRepositoryMockGetAllParams contains parameters of the TagRepository.GetAll
-type TagRepositoryMockGetAllParams struct {
-	ctx context.Context
-}
-
-// TagRepositoryMockGetAllResults contains results of the TagRepository.GetAll
-type TagRepositoryMockGetAllResults struct {
-	ta1 []models.Tag
-	err error
-}
-
-// Expect sets up expected params for TagRepository.GetAll
-func (mmGetAll *mTagRepositoryMockGetAll) Expect(ctx context.Context) *mTagRepositoryMockGetAll {
-	if mmGetAll.mock.funcGetAll != nil {
-		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by Set")
-	}
-
-	if mmGetAll.defaultExpectation == nil {
-		mmGetAll.defaultExpectation = &TagRepositoryMockGetAllExpectation{}
-	}
-
-	mmGetAll.defaultExpectation.params = &TagRepositoryMockGetAllParams{ctx}
-	for _, e := range mmGetAll.expectations {
-		if minimock.Equal(e.params, mmGetAll.defaultExpectation.params) {
-			mmGetAll.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAll.defaultExpectation.params)
-		}
-	}
-
-	return mmGetAll
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.GetAll
-func (mmGetAll *mTagRepositoryMockGetAll) Inspect(f func(ctx context.Context)) *mTagRepositoryMockGetAll {
-	if mmGetAll.mock.inspectFuncGetAll != nil {
-		mmGetAll.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetAll")
-	}
-
-	mmGetAll.mock.inspectFuncGetAll = f
-
-	return mmGetAll
-}
-
-// Return sets up results that will be returned by TagRepository.GetAll
-func (mmGetAll *mTagRepositoryMockGetAll) Return(ta1 []models.Tag, err error) *TagRepositoryMock {
-	if mmGetAll.mock.funcGetAll != nil {
-		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by Set")
-	}
-
-	if mmGetAll.defaultExpectation == nil {
-		mmGetAll.defaultExpectation = &TagRepositoryMockGetAllExpectation{mock: mmGetAll.mock}
-	}
-	mmGetAll.defaultExpectation.results = &TagRepositoryMockGetAllResults{ta1, err}
-	return mmGetAll.mock
-}
-
-// Set uses given function f to mock the TagRepository.GetAll method
-func (mmGetAll *mTagRepositoryMockGetAll) Set(f func(ctx context.Context) (ta1 []models.Tag, err error)) *TagRepositoryMock {
-	if mmGetAll.defaultExpectation != nil {
-		mmGetAll.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetAll method")
-	}
-
-	if len(mmGetAll.expectations) > 0 {
-		mmGetAll.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetAll method")
-	}
-
-	mmGetAll.mock.funcGetAll = f
-	return mmGetAll.mock
-}
-
-// When sets expectation for the TagRepository.GetAll which will trigger the result defined by the following
-// Then helper
-func (mmGetAll *mTagRepositoryMockGetAll) When(ctx context.Context) *TagRepositoryMockGetAllExpectation {
-	if mmGetAll.mock.funcGetAll != nil {
-		mmGetAll.mock.t.Fatalf("TagRepositoryMock.GetAll mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockGetAllExpectation{
-		mock:   mmGetAll.mock,
-		params: &TagRepositoryMockGetAllParams{ctx},
-	}
-	mmGetAll.expectations = append(mmGetAll.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.GetAll return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockGetAllExpectation) Then(ta1 []models.Tag, err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockGetAllResults{ta1, err}
-	return e.mock
-}
-
-// GetAll implements interfaces.TagRepository
-func (mmGetAll *TagRepositoryMock) GetAll(ctx context.Context) (ta1 []models.Tag, err error) {
-	mm_atomic.AddUint64(&mmGetAll.beforeGetAllCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetAll.afterGetAllCounter, 1)
-
-	if mmGetAll.inspectFuncGetAll != nil {
-		mmGetAll.inspectFuncGetAll(ctx)
-	}
-
-	mm_params := &TagRepositoryMockGetAllParams{ctx}
-
-	// Record call args
-	mmGetAll.GetAllMock.mutex.Lock()
-	mmGetAll.GetAllMock.callArgs = append(mmGetAll.GetAllMock.callArgs, mm_params)
-	mmGetAll.GetAllMock.mutex.Unlock()
-
-	for _, e := range mmGetAll.GetAllMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.ta1, e.results.err
-		}
-	}
-
-	if mmGetAll.GetAllMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetAll.GetAllMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetAll.GetAllMock.defaultExpectation.params
-		mm_got := TagRepositoryMockGetAllParams{ctx}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetAll.t.Errorf("TagRepositoryMock.GetAll got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetAll.GetAllMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetAll.t.Fatal("No results are set for the TagRepositoryMock.GetAll")
-		}
-		return (*mm_results).ta1, (*mm_results).err
-	}
-	if mmGetAll.funcGetAll != nil {
-		return mmGetAll.funcGetAll(ctx)
-	}
-	mmGetAll.t.Fatalf("Unexpected call to TagRepositoryMock.GetAll. %v", ctx)
-	return
-}
-
-// GetAllAfterCounter returns a count of finished TagRepositoryMock.GetAll invocations
-func (mmGetAll *TagRepositoryMock) GetAllAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetAll.afterGetAllCounter)
-}
-
-// GetAllBeforeCounter returns a count of TagRepositoryMock.GetAll invocations
-func (mmGetAll *TagRepositoryMock) GetAllBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetAll.beforeGetAllCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.GetAll.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetAll *mTagRepositoryMockGetAll) Calls() []*TagRepositoryMockGetAllParams {
-	mmGetAll.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockGetAllParams, len(mmGetAll.callArgs))
-	copy(argCopy, mmGetAll.callArgs)
-
-	mmGetAll.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetAllDone returns true if the count of the GetAll invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockGetAllDone() bool {
-	for _, e := range m.GetAllMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetAll != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetAllInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockGetAllInspect() {
-	for _, e := range m.GetAllMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetAll with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
-		if m.GetAllMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.GetAll")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetAll with params: %#v", *m.GetAllMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetAll != nil && mm_atomic.LoadUint64(&m.afterGetAllCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.GetAll")
-	}
-}
-
-type mTagRepositoryMockGetAllUsed struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockGetAllUsedExpectation
-	expectations       []*TagRepositoryMockGetAllUsedExpectation
-
-	callArgs []*TagRepositoryMockGetAllUsedParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockGetAllUsedExpectation specifies expectation struct of the TagRepository.GetAllUsed
-type TagRepositoryMockGetAllUsedExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockGetAllUsedParams
-	results *TagRepositoryMockGetAllUsedResults
-	Counter uint64
-}
-
-// TagRepositoryMockGetAllUsedParams contains parameters of the TagRepository.GetAllUsed
-type TagRepositoryMockGetAllUsedParams struct {
-	ctx context.Context
-}
-
-// TagRepositoryMockGetAllUsedResults contains results of the TagRepository.GetAllUsed
-type TagRepositoryMockGetAllUsedResults struct {
-	ta1 []models.Tag
-	err error
-}
-
-// Expect sets up expected params for TagRepository.GetAllUsed
-func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Expect(ctx context.Context) *mTagRepositoryMockGetAllUsed {
-	if mmGetAllUsed.mock.funcGetAllUsed != nil {
-		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
-	}
-
-	if mmGetAllUsed.defaultExpectation == nil {
-		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{}
-	}
-
-	mmGetAllUsed.defaultExpectation.params = &TagRepositoryMockGetAllUsedParams{ctx}
-	for _, e := range mmGetAllUsed.expectations {
-		if minimock.Equal(e.params, mmGetAllUsed.defaultExpectation.params) {
-			mmGetAllUsed.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllUsed.defaultExpectation.params)
-		}
-	}
-
-	return mmGetAllUsed
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.GetAllUsed
-func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Inspect(f func(ctx context.Context)) *mTagRepositoryMockGetAllUsed {
-	if mmGetAllUsed.mock.inspectFuncGetAllUsed != nil {
-		mmGetAllUsed.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetAllUsed")
-	}
-
-	mmGetAllUsed.mock.inspectFuncGetAllUsed = f
-
-	return mmGetAllUsed
-}
-
-// Return sets up results that will be returned by TagRepository.GetAllUsed
-func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Return(ta1 []models.Tag, err error) *TagRepositoryMock {
-	if mmGetAllUsed.mock.funcGetAllUsed != nil {
-		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
-	}
-
-	if mmGetAllUsed.defaultExpectation == nil {
-		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{mock: mmGetAllUsed.mock}
-	}
-	mmGetAllUsed.defaultExpectation.results = &TagRepositoryMockGetAllUsedResults{ta1, err}
-	return mmGetAllUsed.mock
-}
-
-// Set uses given function f to mock the TagRepository.GetAllUsed method
-func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Set(f func(ctx context.Context) (ta1 []models.Tag, err error)) *TagRepositoryMock {
-	if mmGetAllUsed.defaultExpectation != nil {
-		mmGetAllUsed.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetAllUsed method")
-	}
-
-	if len(mmGetAllUsed.expectations) > 0 {
-		mmGetAllUsed.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetAllUsed method")
-	}
-
-	mmGetAllUsed.mock.funcGetAllUsed = f
-	return mmGetAllUsed.mock
-}
-
-// When sets expectation for the TagRepository.GetAllUsed which will trigger the result defined by the following
-// Then helper
-func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) When(ctx context.Context) *TagRepositoryMockGetAllUsedExpectation {
-	if mmGetAllUsed.mock.funcGetAllUsed != nil {
-		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockGetAllUsedExpectation{
-		mock:   mmGetAllUsed.mock,
-		params: &TagRepositoryMockGetAllUsedParams{ctx},
-	}
-	mmGetAllUsed.expectations = append(mmGetAllUsed.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.GetAllUsed return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockGetAllUsedExpectation) Then(ta1 []models.Tag, err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockGetAllUsedResults{ta1, err}
-	return e.mock
-}
-
-// GetAllUsed implements interfaces.TagRepository
-func (mmGetAllUsed *TagRepositoryMock) GetAllUsed(ctx context.Context) (ta1 []models.Tag, err error) {
-	mm_atomic.AddUint64(&mmGetAllUsed.beforeGetAllUsedCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetAllUsed.afterGetAllUsedCounter, 1)
-
-	if mmGetAllUsed.inspectFuncGetAllUsed != nil {
-		mmGetAllUsed.inspectFuncGetAllUsed(ctx)
-	}
-
-	mm_params := &TagRepositoryMockGetAllUsedParams{ctx}
-
-	// Record call args
-	mmGetAllUsed.GetAllUsedMock.mutex.Lock()
-	mmGetAllUsed.GetAllUsedMock.callArgs = append(mmGetAllUsed.GetAllUsedMock.callArgs, mm_params)
-	mmGetAllUsed.GetAllUsedMock.mutex.Unlock()
-
-	for _, e := range mmGetAllUsed.GetAllUsedMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.ta1, e.results.err
-		}
-	}
-
-	if mmGetAllUsed.GetAllUsedMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetAllUsed.GetAllUsedMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetAllUsed.GetAllUsedMock.defaultExpectation.params
-		mm_got := TagRepositoryMockGetAllUsedParams{ctx}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetAllUsed.t.Errorf("TagRepositoryMock.GetAllUsed got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetAllUsed.GetAllUsedMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetAllUsed.t.Fatal("No results are set for the TagRepositoryMock.GetAllUsed")
-		}
-		return (*mm_results).ta1, (*mm_results).err
-	}
-	if mmGetAllUsed.funcGetAllUsed != nil {
-		return mmGetAllUsed.funcGetAllUsed(ctx)
-	}
-	mmGetAllUsed.t.Fatalf("Unexpected call to TagRepositoryMock.GetAllUsed. %v", ctx)
-	return
-}
-
-// GetAllUsedAfterCounter returns a count of finished TagRepositoryMock.GetAllUsed invocations
-func (mmGetAllUsed *TagRepositoryMock) GetAllUsedAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetAllUsed.afterGetAllUsedCounter)
-}
-
-// GetAllUsedBeforeCounter returns a count of TagRepositoryMock.GetAllUsed invocations
-func (mmGetAllUsed *TagRepositoryMock) GetAllUsedBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetAllUsed.beforeGetAllUsedCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.GetAllUsed.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Calls() []*TagRepositoryMockGetAllUsedParams {
-	mmGetAllUsed.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockGetAllUsedParams, len(mmGetAllUsed.callArgs))
-	copy(argCopy, mmGetAllUsed.callArgs)
-
-	mmGetAllUsed.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetAllUsedDone returns true if the count of the GetAllUsed invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockGetAllUsedDone() bool {
-	for _, e := range m.GetAllUsedMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetAllUsedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllUsedCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetAllUsed != nil && mm_atomic.LoadUint64(&m.afterGetAllUsedCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetAllUsedInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockGetAllUsedInspect() {
-	for _, e := range m.GetAllUsedMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetAllUsed with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetAllUsedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetAllUsedCounter) < 1 {
-		if m.GetAllUsedMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.GetAllUsed")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetAllUsed with params: %#v", *m.GetAllUsedMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetAllUsed != nil && mm_atomic.LoadUint64(&m.afterGetAllUsedCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.GetAllUsed")
-	}
-}
-
-type mTagRepositoryMockGetByArticleID struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockGetByArticleIDExpectation
-	expectations       []*TagRepositoryMockGetByArticleIDExpectation
-
-	callArgs []*TagRepositoryMockGetByArticleIDParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockGetByArticleIDExpectation specifies expectation struct of the TagRepository.GetByArticleID
-type TagRepositoryMockGetByArticleIDExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockGetByArticleIDParams
-	results *TagRepositoryMockGetByArticleIDResults
-	Counter uint64
-}
-
-// TagRepositoryMockGetByArticleIDParams contains parameters of the TagRepository.GetByArticleID
-type TagRepositoryMockGetByArticleIDParams struct {
-	ctx context.Context
-	ID  int
-}
-
-// TagRepositoryMockGetByArticleIDResults contains results of the TagRepository.GetByArticleID
-type TagRepositoryMockGetByArticleIDResults struct {
-	ta1 []models.Tag
-	err error
-}
-
-// Expect sets up expected params for TagRepository.GetByArticleID
-func (mmGetByArticleID *mTagRepositoryMockGetByArticleID) Expect(ctx context.Context, ID int) *mTagRepositoryMockGetByArticleID {
-	if mmGetByArticleID.mock.funcGetByArticleID != nil {
-		mmGetByArticleID.mock.t.Fatalf("TagRepositoryMock.GetByArticleID mock is already set by Set")
-	}
-
-	if mmGetByArticleID.defaultExpectation == nil {
-		mmGetByArticleID.defaultExpectation = &TagRepositoryMockGetByArticleIDExpectation{}
-	}
-
-	mmGetByArticleID.defaultExpectation.params = &TagRepositoryMockGetByArticleIDParams{ctx, ID}
-	for _, e := range mmGetByArticleID.expectations {
-		if minimock.Equal(e.params, mmGetByArticleID.defaultExpectation.params) {
-			mmGetByArticleID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByArticleID.defaultExpectation.params)
-		}
-	}
-
-	return mmGetByArticleID
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.GetByArticleID
-func (mmGetByArticleID *mTagRepositoryMockGetByArticleID) Inspect(f func(ctx context.Context, ID int)) *mTagRepositoryMockGetByArticleID {
-	if mmGetByArticleID.mock.inspectFuncGetByArticleID != nil {
-		mmGetByArticleID.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetByArticleID")
-	}
-
-	mmGetByArticleID.mock.inspectFuncGetByArticleID = f
-
-	return mmGetByArticleID
-}
-
-// Return sets up results that will be returned by TagRepository.GetByArticleID
-func (mmGetByArticleID *mTagRepositoryMockGetByArticleID) Return(ta1 []models.Tag, err error) *TagRepositoryMock {
-	if mmGetByArticleID.mock.funcGetByArticleID != nil {
-		mmGetByArticleID.mock.t.Fatalf("TagRepositoryMock.GetByArticleID mock is already set by Set")
-	}
-
-	if mmGetByArticleID.defaultExpectation == nil {
-		mmGetByArticleID.defaultExpectation = &TagRepositoryMockGetByArticleIDExpectation{mock: mmGetByArticleID.mock}
-	}
-	mmGetByArticleID.defaultExpectation.results = &TagRepositoryMockGetByArticleIDResults{ta1, err}
-	return mmGetByArticleID.mock
-}
-
-// Set uses given function f to mock the TagRepository.GetByArticleID method
-func (mmGetByArticleID *mTagRepositoryMockGetByArticleID) Set(f func(ctx context.Context, ID int) (ta1 []models.Tag, err error)) *TagRepositoryMock {
-	if mmGetByArticleID.defaultExpectation != nil {
-		mmGetByArticleID.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetByArticleID method")
-	}
-
-	if len(mmGetByArticleID.expectations) > 0 {
-		mmGetByArticleID.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetByArticleID method")
-	}
-
-	mmGetByArticleID.mock.funcGetByArticleID = f
-	return mmGetByArticleID.mock
-}
-
-// When sets expectation for the TagRepository.GetByArticleID which will trigger the result defined by the following
-// Then helper
-func (mmGetByArticleID *mTagRepositoryMockGetByArticleID) When(ctx context.Context, ID int) *TagRepositoryMockGetByArticleIDExpectation {
-	if mmGetByArticleID.mock.funcGetByArticleID != nil {
-		mmGetByArticleID.mock.t.Fatalf("TagRepositoryMock.GetByArticleID mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockGetByArticleIDExpectation{
-		mock:   mmGetByArticleID.mock,
-		params: &TagRepositoryMockGetByArticleIDParams{ctx, ID},
-	}
-	mmGetByArticleID.expectations = append(mmGetByArticleID.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.GetByArticleID return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockGetByArticleIDExpectation) Then(ta1 []models.Tag, err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockGetByArticleIDResults{ta1, err}
-	return e.mock
-}
-
-// GetByArticleID implements interfaces.TagRepository
-func (mmGetByArticleID *TagRepositoryMock) GetByArticleID(ctx context.Context, ID int) (ta1 []models.Tag, err error) {
-	mm_atomic.AddUint64(&mmGetByArticleID.beforeGetByArticleIDCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetByArticleID.afterGetByArticleIDCounter, 1)
-
-	if mmGetByArticleID.inspectFuncGetByArticleID != nil {
-		mmGetByArticleID.inspectFuncGetByArticleID(ctx, ID)
-	}
-
-	mm_params := &TagRepositoryMockGetByArticleIDParams{ctx, ID}
-
-	// Record call args
-	mmGetByArticleID.GetByArticleIDMock.mutex.Lock()
-	mmGetByArticleID.GetByArticleIDMock.callArgs = append(mmGetByArticleID.GetByArticleIDMock.callArgs, mm_params)
-	mmGetByArticleID.GetByArticleIDMock.mutex.Unlock()
-
-	for _, e := range mmGetByArticleID.GetByArticleIDMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.ta1, e.results.err
-		}
-	}
-
-	if mmGetByArticleID.GetByArticleIDMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetByArticleID.GetByArticleIDMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetByArticleID.GetByArticleIDMock.defaultExpectation.params
-		mm_got := TagRepositoryMockGetByArticleIDParams{ctx, ID}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetByArticleID.t.Errorf("TagRepositoryMock.GetByArticleID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetByArticleID.GetByArticleIDMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetByArticleID.t.Fatal("No results are set for the TagRepositoryMock.GetByArticleID")
-		}
-		return (*mm_results).ta1, (*mm_results).err
-	}
-	if mmGetByArticleID.funcGetByArticleID != nil {
-		return mmGetByArticleID.funcGetByArticleID(ctx, ID)
-	}
-	mmGetByArticleID.t.Fatalf("Unexpected call to TagRepositoryMock.GetByArticleID. %v %v", ctx, ID)
-	return
-}
-
-// GetByArticleIDAfterCounter returns a count of finished TagRepositoryMock.GetByArticleID invocations
-func (mmGetByArticleID *TagRepositoryMock) GetByArticleIDAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByArticleID.afterGetByArticleIDCounter)
-}
-
-// GetByArticleIDBeforeCounter returns a count of TagRepositoryMock.GetByArticleID invocations
-func (mmGetByArticleID *TagRepositoryMock) GetByArticleIDBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByArticleID.beforeGetByArticleIDCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.GetByArticleID.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetByArticleID *mTagRepositoryMockGetByArticleID) Calls() []*TagRepositoryMockGetByArticleIDParams {
-	mmGetByArticleID.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockGetByArticleIDParams, len(mmGetByArticleID.callArgs))
-	copy(argCopy, mmGetByArticleID.callArgs)
-
-	mmGetByArticleID.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetByArticleIDDone returns true if the count of the GetByArticleID invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockGetByArticleIDDone() bool {
-	for _, e := range m.GetByArticleIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByArticleIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByArticleIDCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByArticleID != nil && mm_atomic.LoadUint64(&m.afterGetByArticleIDCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetByArticleIDInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockGetByArticleIDInspect() {
-	for _, e := range m.GetByArticleIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetByArticleID with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByArticleIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByArticleIDCounter) < 1 {
-		if m.GetByArticleIDMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.GetByArticleID")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetByArticleID with params: %#v", *m.GetByArticleIDMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByArticleID != nil && mm_atomic.LoadUint64(&m.afterGetByArticleIDCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.GetByArticleID")
-	}
-}
-
-type mTagRepositoryMockGetByID struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockGetByIDExpectation
-	expectations       []*TagRepositoryMockGetByIDExpectation
-
-	callArgs []*TagRepositoryMockGetByIDParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockGetByIDExpectation specifies expectation struct of the TagRepository.GetByID
-type TagRepositoryMockGetByIDExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockGetByIDParams
-	results *TagRepositoryMockGetByIDResults
-	Counter uint64
-}
-
-// TagRepositoryMockGetByIDParams contains parameters of the TagRepository.GetByID
-type TagRepositoryMockGetByIDParams struct {
-	ctx context.Context
-	ID  int
-}
-
-// TagRepositoryMockGetByIDResults contains results of the TagRepository.GetByID
-type TagRepositoryMockGetByIDResults struct {
-	tp1 *models.Tag
-	err error
-}
-
-// Expect sets up expected params for TagRepository.GetByID
-func (mmGetByID *mTagRepositoryMockGetByID) Expect(ctx context.Context, ID int) *mTagRepositoryMockGetByID {
-	if mmGetByID.mock.funcGetByID != nil {
-		mmGetByID.mock.t.Fatalf("TagRepositoryMock.GetByID mock is already set by Set")
-	}
-
-	if mmGetByID.defaultExpectation == nil {
-		mmGetByID.defaultExpectation = &TagRepositoryMockGetByIDExpectation{}
-	}
-
-	mmGetByID.defaultExpectation.params = &TagRepositoryMockGetByIDParams{ctx, ID}
-	for _, e := range mmGetByID.expectations {
-		if minimock.Equal(e.params, mmGetByID.defaultExpectation.params) {
-			mmGetByID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByID.defaultExpectation.params)
-		}
-	}
-
-	return mmGetByID
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.GetByID
-func (mmGetByID *mTagRepositoryMockGetByID) Inspect(f func(ctx context.Context, ID int)) *mTagRepositoryMockGetByID {
-	if mmGetByID.mock.inspectFuncGetByID != nil {
-		mmGetByID.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetByID")
-	}
-
-	mmGetByID.mock.inspectFuncGetByID = f
-
-	return mmGetByID
-}
-
-// Return sets up results that will be returned by TagRepository.GetByID
-func (mmGetByID *mTagRepositoryMockGetByID) Return(tp1 *models.Tag, err error) *TagRepositoryMock {
-	if mmGetByID.mock.funcGetByID != nil {
-		mmGetByID.mock.t.Fatalf("TagRepositoryMock.GetByID mock is already set by Set")
-	}
-
-	if mmGetByID.defaultExpectation == nil {
-		mmGetByID.defaultExpectation = &TagRepositoryMockGetByIDExpectation{mock: mmGetByID.mock}
-	}
-	mmGetByID.defaultExpectation.results = &TagRepositoryMockGetByIDResults{tp1, err}
-	return mmGetByID.mock
-}
-
-// Set uses given function f to mock the TagRepository.GetByID method
-func (mmGetByID *mTagRepositoryMockGetByID) Set(f func(ctx context.Context, ID int) (tp1 *models.Tag, err error)) *TagRepositoryMock {
-	if mmGetByID.defaultExpectation != nil {
-		mmGetByID.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetByID method")
-	}
-
-	if len(mmGetByID.expectations) > 0 {
-		mmGetByID.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetByID method")
-	}
-
-	mmGetByID.mock.funcGetByID = f
-	return mmGetByID.mock
-}
-
-// When sets expectation for the TagRepository.GetByID which will trigger the result defined by the following
-// Then helper
-func (mmGetByID *mTagRepositoryMockGetByID) When(ctx context.Context, ID int) *TagRepositoryMockGetByIDExpectation {
-	if mmGetByID.mock.funcGetByID != nil {
-		mmGetByID.mock.t.Fatalf("TagRepositoryMock.GetByID mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockGetByIDExpectation{
-		mock:   mmGetByID.mock,
-		params: &TagRepositoryMockGetByIDParams{ctx, ID},
-	}
-	mmGetByID.expectations = append(mmGetByID.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.GetByID return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockGetByIDExpectation) Then(tp1 *models.Tag, err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockGetByIDResults{tp1, err}
-	return e.mock
-}
-
-// GetByID implements interfaces.TagRepository
-func (mmGetByID *TagRepositoryMock) GetByID(ctx context.Context, ID int) (tp1 *models.Tag, err error) {
-	mm_atomic.AddUint64(&mmGetByID.beforeGetByIDCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetByID.afterGetByIDCounter, 1)
-
-	if mmGetByID.inspectFuncGetByID != nil {
-		mmGetByID.inspectFuncGetByID(ctx, ID)
-	}
-
-	mm_params := &TagRepositoryMockGetByIDParams{ctx, ID}
-
-	// Record call args
-	mmGetByID.GetByIDMock.mutex.Lock()
-	mmGetByID.GetByIDMock.callArgs = append(mmGetByID.GetByIDMock.callArgs, mm_params)
-	mmGetByID.GetByIDMock.mutex.Unlock()
-
-	for _, e := range mmGetByID.GetByIDMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.tp1, e.results.err
-		}
-	}
-
-	if mmGetByID.GetByIDMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetByID.GetByIDMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetByID.GetByIDMock.defaultExpectation.params
-		mm_got := TagRepositoryMockGetByIDParams{ctx, ID}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetByID.t.Errorf("TagRepositoryMock.GetByID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetByID.GetByIDMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetByID.t.Fatal("No results are set for the TagRepositoryMock.GetByID")
-		}
-		return (*mm_results).tp1, (*mm_results).err
-	}
-	if mmGetByID.funcGetByID != nil {
-		return mmGetByID.funcGetByID(ctx, ID)
-	}
-	mmGetByID.t.Fatalf("Unexpected call to TagRepositoryMock.GetByID. %v %v", ctx, ID)
-	return
-}
-
-// GetByIDAfterCounter returns a count of finished TagRepositoryMock.GetByID invocations
-func (mmGetByID *TagRepositoryMock) GetByIDAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByID.afterGetByIDCounter)
-}
-
-// GetByIDBeforeCounter returns a count of TagRepositoryMock.GetByID invocations
-func (mmGetByID *TagRepositoryMock) GetByIDBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByID.beforeGetByIDCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.GetByID.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetByID *mTagRepositoryMockGetByID) Calls() []*TagRepositoryMockGetByIDParams {
-	mmGetByID.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockGetByIDParams, len(mmGetByID.callArgs))
-	copy(argCopy, mmGetByID.callArgs)
-
-	mmGetByID.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetByIDDone returns true if the count of the GetByID invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockGetByIDDone() bool {
-	for _, e := range m.GetByIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByID != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetByIDInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockGetByIDInspect() {
-	for _, e := range m.GetByIDMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetByID with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
-		if m.GetByIDMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.GetByID")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetByID with params: %#v", *m.GetByIDMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByID != nil && mm_atomic.LoadUint64(&m.afterGetByIDCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.GetByID")
-	}
-}
-
-type mTagRepositoryMockGetByURL struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockGetByURLExpectation
-	expectations       []*TagRepositoryMockGetByURLExpectation
-
-	callArgs []*TagRepositoryMockGetByURLParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockGetByURLExpectation specifies expectation struct of the TagRepository.GetByURL
-type TagRepositoryMockGetByURLExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockGetByURLParams
-	results *TagRepositoryMockGetByURLResults
-	Counter uint64
-}
-
-// TagRepositoryMockGetByURLParams contains parameters of the TagRepository.GetByURL
-type TagRepositoryMockGetByURLParams struct {
-	ctx context.Context
-	tag string
-}
-
-// TagRepositoryMockGetByURLResults contains results of the TagRepository.GetByURL
-type TagRepositoryMockGetByURLResults struct {
-	tp1 *models.Tag
-	err error
-}
-
-// Expect sets up expected params for TagRepository.GetByURL
-func (mmGetByURL *mTagRepositoryMockGetByURL) Expect(ctx context.Context, tag string) *mTagRepositoryMockGetByURL {
-	if mmGetByURL.mock.funcGetByURL != nil {
-		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
-	}
-
-	if mmGetByURL.defaultExpectation == nil {
-		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{}
-	}
-
-	mmGetByURL.defaultExpectation.params = &TagRepositoryMockGetByURLParams{ctx, tag}
-	for _, e := range mmGetByURL.expectations {
-		if minimock.Equal(e.params, mmGetByURL.defaultExpectation.params) {
-			mmGetByURL.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByURL.defaultExpectation.params)
-		}
-	}
-
-	return mmGetByURL
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.GetByURL
-func (mmGetByURL *mTagRepositoryMockGetByURL) Inspect(f func(ctx context.Context, tag string)) *mTagRepositoryMockGetByURL {
-	if mmGetByURL.mock.inspectFuncGetByURL != nil {
-		mmGetByURL.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetByURL")
-	}
-
-	mmGetByURL.mock.inspectFuncGetByURL = f
-
-	return mmGetByURL
-}
-
-// Return sets up results that will be returned by TagRepository.GetByURL
-func (mmGetByURL *mTagRepositoryMockGetByURL) Return(tp1 *models.Tag, err error) *TagRepositoryMock {
-	if mmGetByURL.mock.funcGetByURL != nil {
-		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
-	}
-
-	if mmGetByURL.defaultExpectation == nil {
-		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock}
-	}
-	mmGetByURL.defaultExpectation.results = &TagRepositoryMockGetByURLResults{tp1, err}
-	return mmGetByURL.mock
-}
-
-// Set uses given function f to mock the TagRepository.GetByURL method
-func (mmGetByURL *mTagRepositoryMockGetByURL) Set(f func(ctx context.Context, tag string) (tp1 *models.Tag, err error)) *TagRepositoryMock {
-	if mmGetByURL.defaultExpectation != nil {
-		mmGetByURL.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetByURL method")
-	}
-
-	if len(mmGetByURL.expectations) > 0 {
-		mmGetByURL.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetByURL method")
-	}
-
-	mmGetByURL.mock.funcGetByURL = f
-	return mmGetByURL.mock
-}
-
-// When sets expectation for the TagRepository.GetByURL which will trigger the result defined by the following
-// Then helper
-func (mmGetByURL *mTagRepositoryMockGetByURL) When(ctx context.Context, tag string) *TagRepositoryMockGetByURLExpectation {
-	if mmGetByURL.mock.funcGetByURL != nil {
-		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockGetByURLExpectation{
-		mock:   mmGetByURL.mock,
-		params: &TagRepositoryMockGetByURLParams{ctx, tag},
-	}
-	mmGetByURL.expectations = append(mmGetByURL.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.GetByURL return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockGetByURLExpectation) Then(tp1 *models.Tag, err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockGetByURLResults{tp1, err}
-	return e.mock
-}
-
-// GetByURL implements interfaces.TagRepository
-func (mmGetByURL *TagRepositoryMock) GetByURL(ctx context.Context, tag string) (tp1 *models.Tag, err error) {
-	mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1)
-
-	if mmGetByURL.inspectFuncGetByURL != nil {
-		mmGetByURL.inspectFuncGetByURL(ctx, tag)
-	}
-
-	mm_params := &TagRepositoryMockGetByURLParams{ctx, tag}
-
-	// Record call args
-	mmGetByURL.GetByURLMock.mutex.Lock()
-	mmGetByURL.GetByURLMock.callArgs = append(mmGetByURL.GetByURLMock.callArgs, mm_params)
-	mmGetByURL.GetByURLMock.mutex.Unlock()
-
-	for _, e := range mmGetByURL.GetByURLMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.tp1, e.results.err
-		}
-	}
-
-	if mmGetByURL.GetByURLMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetByURL.GetByURLMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetByURL.GetByURLMock.defaultExpectation.params
-		mm_got := TagRepositoryMockGetByURLParams{ctx, tag}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetByURL.t.Errorf("TagRepositoryMock.GetByURL got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetByURL.t.Fatal("No results are set for the TagRepositoryMock.GetByURL")
-		}
-		return (*mm_results).tp1, (*mm_results).err
-	}
-	if mmGetByURL.funcGetByURL != nil {
-		return mmGetByURL.funcGetByURL(ctx, tag)
-	}
-	mmGetByURL.t.Fatalf("Unexpected call to TagRepositoryMock.GetByURL. %v %v", ctx, tag)
-	return
-}
-
-// GetByURLAfterCounter returns a count of finished TagRepositoryMock.GetByURL invocations
-func (mmGetByURL *TagRepositoryMock) GetByURLAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter)
-}
-
-// GetByURLBeforeCounter returns a count of TagRepositoryMock.GetByURL invocations
-func (mmGetByURL *TagRepositoryMock) GetByURLBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.GetByURL.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetByURL *mTagRepositoryMockGetByURL) Calls() []*TagRepositoryMockGetByURLParams {
-	mmGetByURL.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockGetByURLParams, len(mmGetByURL.callArgs))
-	copy(argCopy, mmGetByURL.callArgs)
-
-	mmGetByURL.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetByURLDone returns true if the count of the GetByURL invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockGetByURLDone() bool {
-	for _, e := range m.GetByURLMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByURLMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByURL != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetByURLInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockGetByURLInspect() {
-	for _, e := range m.GetByURLMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetByURL with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetByURLMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
-		if m.GetByURLMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.GetByURL")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.GetByURL with params: %#v", *m.GetByURLMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetByURL != nil && mm_atomic.LoadUint64(&m.afterGetByURLCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.GetByURL")
-	}
-}
-
-type mTagRepositoryMockIsUsed struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockIsUsedExpectation
-	expectations       []*TagRepositoryMockIsUsedExpectation
-
-	callArgs []*TagRepositoryMockIsUsedParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockIsUsedExpectation specifies expectation struct of the TagRepository.IsUsed
-type TagRepositoryMockIsUsedExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockIsUsedParams
-	results *TagRepositoryMockIsUsedResults
-	Counter uint64
-}
-
-// TagRepositoryMockIsUsedParams contains parameters of the TagRepository.IsUsed
-type TagRepositoryMockIsUsedParams struct {
-	ctx context.Context
-	ID  int
-}
-
-// TagRepositoryMockIsUsedResults contains results of the TagRepository.IsUsed
-type TagRepositoryMockIsUsedResults struct {
-	b1  bool
-	err error
-}
-
-// Expect sets up expected params for TagRepository.IsUsed
-func (mmIsUsed *mTagRepositoryMockIsUsed) Expect(ctx context.Context, ID int) *mTagRepositoryMockIsUsed {
-	if mmIsUsed.mock.funcIsUsed != nil {
-		mmIsUsed.mock.t.Fatalf("TagRepositoryMock.IsUsed mock is already set by Set")
-	}
-
-	if mmIsUsed.defaultExpectation == nil {
-		mmIsUsed.defaultExpectation = &TagRepositoryMockIsUsedExpectation{}
-	}
-
-	mmIsUsed.defaultExpectation.params = &TagRepositoryMockIsUsedParams{ctx, ID}
-	for _, e := range mmIsUsed.expectations {
-		if minimock.Equal(e.params, mmIsUsed.defaultExpectation.params) {
-			mmIsUsed.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIsUsed.defaultExpectation.params)
-		}
-	}
-
-	return mmIsUsed
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.IsUsed
-func (mmIsUsed *mTagRepositoryMockIsUsed) Inspect(f func(ctx context.Context, ID int)) *mTagRepositoryMockIsUsed {
-	if mmIsUsed.mock.inspectFuncIsUsed != nil {
-		mmIsUsed.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.IsUsed")
-	}
-
-	mmIsUsed.mock.inspectFuncIsUsed = f
-
-	return mmIsUsed
-}
-
-// Return sets up results that will be returned by TagRepository.IsUsed
-func (mmIsUsed *mTagRepositoryMockIsUsed) Return(b1 bool, err error) *TagRepositoryMock {
-	if mmIsUsed.mock.funcIsUsed != nil {
-		mmIsUsed.mock.t.Fatalf("TagRepositoryMock.IsUsed mock is already set by Set")
-	}
-
-	if mmIsUsed.defaultExpectation == nil {
-		mmIsUsed.defaultExpectation = &TagRepositoryMockIsUsedExpectation{mock: mmIsUsed.mock}
-	}
-	mmIsUsed.defaultExpectation.results = &TagRepositoryMockIsUsedResults{b1, err}
-	return mmIsUsed.mock
-}
-
-// Set uses given function f to mock the TagRepository.IsUsed method
-func (mmIsUsed *mTagRepositoryMockIsUsed) Set(f func(ctx context.Context, ID int) (b1 bool, err error)) *TagRepositoryMock {
-	if mmIsUsed.defaultExpectation != nil {
-		mmIsUsed.mock.t.Fatalf("Default expectation is already set for the TagRepository.IsUsed method")
-	}
-
-	if len(mmIsUsed.expectations) > 0 {
-		mmIsUsed.mock.t.Fatalf("Some expectations are already set for the TagRepository.IsUsed method")
-	}
-
-	mmIsUsed.mock.funcIsUsed = f
-	return mmIsUsed.mock
-}
-
-// When sets expectation for the TagRepository.IsUsed which will trigger the result defined by the following
-// Then helper
-func (mmIsUsed *mTagRepositoryMockIsUsed) When(ctx context.Context, ID int) *TagRepositoryMockIsUsedExpectation {
-	if mmIsUsed.mock.funcIsUsed != nil {
-		mmIsUsed.mock.t.Fatalf("TagRepositoryMock.IsUsed mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockIsUsedExpectation{
-		mock:   mmIsUsed.mock,
-		params: &TagRepositoryMockIsUsedParams{ctx, ID},
-	}
-	mmIsUsed.expectations = append(mmIsUsed.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.IsUsed return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockIsUsedExpectation) Then(b1 bool, err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockIsUsedResults{b1, err}
-	return e.mock
-}
-
-// IsUsed implements interfaces.TagRepository
-func (mmIsUsed *TagRepositoryMock) IsUsed(ctx context.Context, ID int) (b1 bool, err error) {
-	mm_atomic.AddUint64(&mmIsUsed.beforeIsUsedCounter, 1)
-	defer mm_atomic.AddUint64(&mmIsUsed.afterIsUsedCounter, 1)
-
-	if mmIsUsed.inspectFuncIsUsed != nil {
-		mmIsUsed.inspectFuncIsUsed(ctx, ID)
-	}
-
-	mm_params := &TagRepositoryMockIsUsedParams{ctx, ID}
-
-	// Record call args
-	mmIsUsed.IsUsedMock.mutex.Lock()
-	mmIsUsed.IsUsedMock.callArgs = append(mmIsUsed.IsUsedMock.callArgs, mm_params)
-	mmIsUsed.IsUsedMock.mutex.Unlock()
-
-	for _, e := range mmIsUsed.IsUsedMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.b1, e.results.err
-		}
-	}
-
-	if mmIsUsed.IsUsedMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmIsUsed.IsUsedMock.defaultExpectation.Counter, 1)
-		mm_want := mmIsUsed.IsUsedMock.defaultExpectation.params
-		mm_got := TagRepositoryMockIsUsedParams{ctx, ID}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmIsUsed.t.Errorf("TagRepositoryMock.IsUsed got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmIsUsed.IsUsedMock.defaultExpectation.results
-		if mm_results == nil {
-			mmIsUsed.t.Fatal("No results are set for the TagRepositoryMock.IsUsed")
-		}
-		return (*mm_results).b1, (*mm_results).err
-	}
-	if mmIsUsed.funcIsUsed != nil {
-		return mmIsUsed.funcIsUsed(ctx, ID)
-	}
-	mmIsUsed.t.Fatalf("Unexpected call to TagRepositoryMock.IsUsed. %v %v", ctx, ID)
-	return
-}
-
-// IsUsedAfterCounter returns a count of finished TagRepositoryMock.IsUsed invocations
-func (mmIsUsed *TagRepositoryMock) IsUsedAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmIsUsed.afterIsUsedCounter)
-}
-
-// IsUsedBeforeCounter returns a count of TagRepositoryMock.IsUsed invocations
-func (mmIsUsed *TagRepositoryMock) IsUsedBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmIsUsed.beforeIsUsedCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.IsUsed.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmIsUsed *mTagRepositoryMockIsUsed) Calls() []*TagRepositoryMockIsUsedParams {
-	mmIsUsed.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockIsUsedParams, len(mmIsUsed.callArgs))
-	copy(argCopy, mmIsUsed.callArgs)
-
-	mmIsUsed.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockIsUsedDone returns true if the count of the IsUsed invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockIsUsedDone() bool {
-	for _, e := range m.IsUsedMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.IsUsedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsUsedCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcIsUsed != nil && mm_atomic.LoadUint64(&m.afterIsUsedCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockIsUsedInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockIsUsedInspect() {
-	for _, e := range m.IsUsedMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.IsUsed with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.IsUsedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsUsedCounter) < 1 {
-		if m.IsUsedMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.IsUsed")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.IsUsed with params: %#v", *m.IsUsedMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcIsUsed != nil && mm_atomic.LoadUint64(&m.afterIsUsedCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.IsUsed")
-	}
-}
-
-type mTagRepositoryMockUpdate struct {
-	mock               *TagRepositoryMock
-	defaultExpectation *TagRepositoryMockUpdateExpectation
-	expectations       []*TagRepositoryMockUpdateExpectation
-
-	callArgs []*TagRepositoryMockUpdateParams
-	mutex    sync.RWMutex
-}
-
-// TagRepositoryMockUpdateExpectation specifies expectation struct of the TagRepository.Update
-type TagRepositoryMockUpdateExpectation struct {
-	mock    *TagRepositoryMock
-	params  *TagRepositoryMockUpdateParams
-	results *TagRepositoryMockUpdateResults
-	Counter uint64
-}
-
-// TagRepositoryMockUpdateParams contains parameters of the TagRepository.Update
-type TagRepositoryMockUpdateParams struct {
-	ctx context.Context
-	m   models.Tag
-}
-
-// TagRepositoryMockUpdateResults contains results of the TagRepository.Update
-type TagRepositoryMockUpdateResults struct {
-	err error
-}
-
-// Expect sets up expected params for TagRepository.Update
-func (mmUpdate *mTagRepositoryMockUpdate) Expect(ctx context.Context, m models.Tag) *mTagRepositoryMockUpdate {
-	if mmUpdate.mock.funcUpdate != nil {
-		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Set")
-	}
-
-	if mmUpdate.defaultExpectation == nil {
-		mmUpdate.defaultExpectation = &TagRepositoryMockUpdateExpectation{}
-	}
-
-	mmUpdate.defaultExpectation.params = &TagRepositoryMockUpdateParams{ctx, m}
-	for _, e := range mmUpdate.expectations {
-		if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
-			mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
-		}
-	}
-
-	return mmUpdate
-}
-
-// Inspect accepts an inspector function that has same arguments as the TagRepository.Update
-func (mmUpdate *mTagRepositoryMockUpdate) Inspect(f func(ctx context.Context, m models.Tag)) *mTagRepositoryMockUpdate {
-	if mmUpdate.mock.inspectFuncUpdate != nil {
-		mmUpdate.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.Update")
-	}
-
-	mmUpdate.mock.inspectFuncUpdate = f
-
-	return mmUpdate
-}
-
-// Return sets up results that will be returned by TagRepository.Update
-func (mmUpdate *mTagRepositoryMockUpdate) Return(err error) *TagRepositoryMock {
-	if mmUpdate.mock.funcUpdate != nil {
-		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Set")
-	}
-
-	if mmUpdate.defaultExpectation == nil {
-		mmUpdate.defaultExpectation = &TagRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
-	}
-	mmUpdate.defaultExpectation.results = &TagRepositoryMockUpdateResults{err}
-	return mmUpdate.mock
-}
-
-// Set uses given function f to mock the TagRepository.Update method
-func (mmUpdate *mTagRepositoryMockUpdate) Set(f func(ctx context.Context, m models.Tag) (err error)) *TagRepositoryMock {
-	if mmUpdate.defaultExpectation != nil {
-		mmUpdate.mock.t.Fatalf("Default expectation is already set for the TagRepository.Update method")
-	}
-
-	if len(mmUpdate.expectations) > 0 {
-		mmUpdate.mock.t.Fatalf("Some expectations are already set for the TagRepository.Update method")
-	}
-
-	mmUpdate.mock.funcUpdate = f
-	return mmUpdate.mock
-}
-
-// When sets expectation for the TagRepository.Update which will trigger the result defined by the following
-// Then helper
-func (mmUpdate *mTagRepositoryMockUpdate) When(ctx context.Context, m models.Tag) *TagRepositoryMockUpdateExpectation {
-	if mmUpdate.mock.funcUpdate != nil {
-		mmUpdate.mock.t.Fatalf("TagRepositoryMock.Update mock is already set by Set")
-	}
-
-	expectation := &TagRepositoryMockUpdateExpectation{
-		mock:   mmUpdate.mock,
-		params: &TagRepositoryMockUpdateParams{ctx, m},
-	}
-	mmUpdate.expectations = append(mmUpdate.expectations, expectation)
-	return expectation
-}
-
-// Then sets up TagRepository.Update return parameters for the expectation previously defined by the When method
-func (e *TagRepositoryMockUpdateExpectation) Then(err error) *TagRepositoryMock {
-	e.results = &TagRepositoryMockUpdateResults{err}
-	return e.mock
-}
-
-// Update implements interfaces.TagRepository
-func (mmUpdate *TagRepositoryMock) Update(ctx context.Context, m models.Tag) (err error) {
-	mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
-	defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)
-
-	if mmUpdate.inspectFuncUpdate != nil {
-		mmUpdate.inspectFuncUpdate(ctx, m)
-	}
-
-	mm_params := &TagRepositoryMockUpdateParams{ctx, m}
-
-	// Record call args
-	mmUpdate.UpdateMock.mutex.Lock()
-	mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, mm_params)
-	mmUpdate.UpdateMock.mutex.Unlock()
-
-	for _, e := range mmUpdate.UpdateMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmUpdate.UpdateMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
-		mm_want := mmUpdate.UpdateMock.defaultExpectation.params
-		mm_got := TagRepositoryMockUpdateParams{ctx, m}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmUpdate.t.Errorf("TagRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmUpdate.UpdateMock.defaultExpectation.results
-		if mm_results == nil {
-			mmUpdate.t.Fatal("No results are set for the TagRepositoryMock.Update")
-		}
-		return (*mm_results).err
-	}
-	if mmUpdate.funcUpdate != nil {
-		return mmUpdate.funcUpdate(ctx, m)
-	}
-	mmUpdate.t.Fatalf("Unexpected call to TagRepositoryMock.Update. %v %v", ctx, m)
-	return
-}
-
-// UpdateAfterCounter returns a count of finished TagRepositoryMock.Update invocations
-func (mmUpdate *TagRepositoryMock) UpdateAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
-}
-
-// UpdateBeforeCounter returns a count of TagRepositoryMock.Update invocations
-func (mmUpdate *TagRepositoryMock) UpdateBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
-}
-
-// Calls returns a list of arguments used in each call to TagRepositoryMock.Update.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmUpdate *mTagRepositoryMockUpdate) Calls() []*TagRepositoryMockUpdateParams {
-	mmUpdate.mutex.RLock()
-
-	argCopy := make([]*TagRepositoryMockUpdateParams, len(mmUpdate.callArgs))
-	copy(argCopy, mmUpdate.callArgs)
-
-	mmUpdate.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockUpdateDone returns true if the count of the Update invocations corresponds
-// the number of defined expectations
-func (m *TagRepositoryMock) MinimockUpdateDone() bool {
-	for _, e := range m.UpdateMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockUpdateInspect logs each unmet expectation
-func (m *TagRepositoryMock) MinimockUpdateInspect() {
-	for _, e := range m.UpdateMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to TagRepositoryMock.Update with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.UpdateMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
-		if m.UpdateMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to TagRepositoryMock.Update")
-		} else {
-			m.t.Errorf("Expected call to TagRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcUpdate != nil && mm_atomic.LoadUint64(&m.afterUpdateCounter) < 1 {
-		m.t.Error("Expected call to TagRepositoryMock.Update")
-	}
-}
-
-// MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *TagRepositoryMock) MinimockFinish() {
-	if !m.minimockDone() {
-		m.MinimockAddInspect()
-
-		m.MinimockDeleteInspect()
-
-		m.MinimockGetAllInspect()
-
-		m.MinimockGetAllUsedInspect()
-
-		m.MinimockGetByArticleIDInspect()
-
-		m.MinimockGetByIDInspect()
-
-		m.MinimockGetByURLInspect()
-
-		m.MinimockIsUsedInspect()
-
-		m.MinimockUpdateInspect()
-		m.t.FailNow()
-	}
-}
-
-// MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *TagRepositoryMock) MinimockWait(timeout mm_time.Duration) {
-	timeoutCh := mm_time.After(timeout)
-	for {
-		if m.minimockDone() {
-			return
-		}
-		select {
-		case <-timeoutCh:
-			m.MinimockFinish()
-			return
-		case <-mm_time.After(10 * mm_time.Millisecond):
-		}
-	}
-}
-
-func (m *TagRepositoryMock) minimockDone() bool {
-	done := true
-	return done &&
-		m.MinimockAddDone() &&
-		m.MinimockDeleteDone() &&
-		m.MinimockGetAllDone() &&
-		m.MinimockGetAllUsedDone() &&
-		m.MinimockGetByArticleIDDone() &&
-		m.MinimockGetByIDDone() &&
-		m.MinimockGetByURLDone() &&
-		m.MinimockIsUsedDone() &&
-		m.MinimockUpdateDone()
-}

+ 0 - 516
internal/repositories/mocks/user_repository_minimock.go

@@ -1,516 +0,0 @@
-package mocks
-
-// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
-
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.UserRepository -o ./mocks/user_repository_minimock.go -n UserRepositoryMock
-
-import (
-	"context"
-	"sync"
-	mm_atomic "sync/atomic"
-	mm_time "time"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	"github.com/gojuno/minimock/v3"
-)
-
-// UserRepositoryMock implements interfaces.UserRepository
-type UserRepositoryMock struct {
-	t minimock.Tester
-
-	funcAdd          func(ctx context.Context, username string, password string) (i1 int, err error)
-	inspectFuncAdd   func(ctx context.Context, username string, password string)
-	afterAddCounter  uint64
-	beforeAddCounter uint64
-	AddMock          mUserRepositoryMockAdd
-
-	funcGet          func(ctx context.Context, username string) (up1 *models.User, err error)
-	inspectFuncGet   func(ctx context.Context, username string)
-	afterGetCounter  uint64
-	beforeGetCounter uint64
-	GetMock          mUserRepositoryMockGet
-}
-
-// NewUserRepositoryMock returns a mock for interfaces.UserRepository
-func NewUserRepositoryMock(t minimock.Tester) *UserRepositoryMock {
-	m := &UserRepositoryMock{t: t}
-	if controller, ok := t.(minimock.MockController); ok {
-		controller.RegisterMocker(m)
-	}
-
-	m.AddMock = mUserRepositoryMockAdd{mock: m}
-	m.AddMock.callArgs = []*UserRepositoryMockAddParams{}
-
-	m.GetMock = mUserRepositoryMockGet{mock: m}
-	m.GetMock.callArgs = []*UserRepositoryMockGetParams{}
-
-	return m
-}
-
-type mUserRepositoryMockAdd struct {
-	mock               *UserRepositoryMock
-	defaultExpectation *UserRepositoryMockAddExpectation
-	expectations       []*UserRepositoryMockAddExpectation
-
-	callArgs []*UserRepositoryMockAddParams
-	mutex    sync.RWMutex
-}
-
-// UserRepositoryMockAddExpectation specifies expectation struct of the UserRepository.Add
-type UserRepositoryMockAddExpectation struct {
-	mock    *UserRepositoryMock
-	params  *UserRepositoryMockAddParams
-	results *UserRepositoryMockAddResults
-	Counter uint64
-}
-
-// UserRepositoryMockAddParams contains parameters of the UserRepository.Add
-type UserRepositoryMockAddParams struct {
-	ctx      context.Context
-	username string
-	password string
-}
-
-// UserRepositoryMockAddResults contains results of the UserRepository.Add
-type UserRepositoryMockAddResults struct {
-	i1  int
-	err error
-}
-
-// Expect sets up expected params for UserRepository.Add
-func (mmAdd *mUserRepositoryMockAdd) Expect(ctx context.Context, username string, password string) *mUserRepositoryMockAdd {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{}
-	}
-
-	mmAdd.defaultExpectation.params = &UserRepositoryMockAddParams{ctx, username, password}
-	for _, e := range mmAdd.expectations {
-		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
-			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
-		}
-	}
-
-	return mmAdd
-}
-
-// Inspect accepts an inspector function that has same arguments as the UserRepository.Add
-func (mmAdd *mUserRepositoryMockAdd) Inspect(f func(ctx context.Context, username string, password string)) *mUserRepositoryMockAdd {
-	if mmAdd.mock.inspectFuncAdd != nil {
-		mmAdd.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.Add")
-	}
-
-	mmAdd.mock.inspectFuncAdd = f
-
-	return mmAdd
-}
-
-// Return sets up results that will be returned by UserRepository.Add
-func (mmAdd *mUserRepositoryMockAdd) Return(i1 int, err error) *UserRepositoryMock {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
-	}
-
-	if mmAdd.defaultExpectation == nil {
-		mmAdd.defaultExpectation = &UserRepositoryMockAddExpectation{mock: mmAdd.mock}
-	}
-	mmAdd.defaultExpectation.results = &UserRepositoryMockAddResults{i1, err}
-	return mmAdd.mock
-}
-
-// Set uses given function f to mock the UserRepository.Add method
-func (mmAdd *mUserRepositoryMockAdd) Set(f func(ctx context.Context, username string, password string) (i1 int, err error)) *UserRepositoryMock {
-	if mmAdd.defaultExpectation != nil {
-		mmAdd.mock.t.Fatalf("Default expectation is already set for the UserRepository.Add method")
-	}
-
-	if len(mmAdd.expectations) > 0 {
-		mmAdd.mock.t.Fatalf("Some expectations are already set for the UserRepository.Add method")
-	}
-
-	mmAdd.mock.funcAdd = f
-	return mmAdd.mock
-}
-
-// When sets expectation for the UserRepository.Add which will trigger the result defined by the following
-// Then helper
-func (mmAdd *mUserRepositoryMockAdd) When(ctx context.Context, username string, password string) *UserRepositoryMockAddExpectation {
-	if mmAdd.mock.funcAdd != nil {
-		mmAdd.mock.t.Fatalf("UserRepositoryMock.Add mock is already set by Set")
-	}
-
-	expectation := &UserRepositoryMockAddExpectation{
-		mock:   mmAdd.mock,
-		params: &UserRepositoryMockAddParams{ctx, username, password},
-	}
-	mmAdd.expectations = append(mmAdd.expectations, expectation)
-	return expectation
-}
-
-// Then sets up UserRepository.Add return parameters for the expectation previously defined by the When method
-func (e *UserRepositoryMockAddExpectation) Then(i1 int, err error) *UserRepositoryMock {
-	e.results = &UserRepositoryMockAddResults{i1, err}
-	return e.mock
-}
-
-// Add implements interfaces.UserRepository
-func (mmAdd *UserRepositoryMock) Add(ctx context.Context, username string, password string) (i1 int, err error) {
-	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
-	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)
-
-	if mmAdd.inspectFuncAdd != nil {
-		mmAdd.inspectFuncAdd(ctx, username, password)
-	}
-
-	mm_params := &UserRepositoryMockAddParams{ctx, username, password}
-
-	// Record call args
-	mmAdd.AddMock.mutex.Lock()
-	mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params)
-	mmAdd.AddMock.mutex.Unlock()
-
-	for _, e := range mmAdd.AddMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.i1, e.results.err
-		}
-	}
-
-	if mmAdd.AddMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
-		mm_want := mmAdd.AddMock.defaultExpectation.params
-		mm_got := UserRepositoryMockAddParams{ctx, username, password}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmAdd.t.Errorf("UserRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmAdd.AddMock.defaultExpectation.results
-		if mm_results == nil {
-			mmAdd.t.Fatal("No results are set for the UserRepositoryMock.Add")
-		}
-		return (*mm_results).i1, (*mm_results).err
-	}
-	if mmAdd.funcAdd != nil {
-		return mmAdd.funcAdd(ctx, username, password)
-	}
-	mmAdd.t.Fatalf("Unexpected call to UserRepositoryMock.Add. %v %v %v", ctx, username, password)
-	return
-}
-
-// AddAfterCounter returns a count of finished UserRepositoryMock.Add invocations
-func (mmAdd *UserRepositoryMock) AddAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
-}
-
-// AddBeforeCounter returns a count of UserRepositoryMock.Add invocations
-func (mmAdd *UserRepositoryMock) AddBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
-}
-
-// Calls returns a list of arguments used in each call to UserRepositoryMock.Add.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmAdd *mUserRepositoryMockAdd) Calls() []*UserRepositoryMockAddParams {
-	mmAdd.mutex.RLock()
-
-	argCopy := make([]*UserRepositoryMockAddParams, len(mmAdd.callArgs))
-	copy(argCopy, mmAdd.callArgs)
-
-	mmAdd.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockAddDone returns true if the count of the Add invocations corresponds
-// the number of defined expectations
-func (m *UserRepositoryMock) MinimockAddDone() bool {
-	for _, e := range m.AddMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockAddInspect logs each unmet expectation
-func (m *UserRepositoryMock) MinimockAddInspect() {
-	for _, e := range m.AddMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to UserRepositoryMock.Add with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		if m.AddMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to UserRepositoryMock.Add")
-		} else {
-			m.t.Errorf("Expected call to UserRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
-		m.t.Error("Expected call to UserRepositoryMock.Add")
-	}
-}
-
-type mUserRepositoryMockGet struct {
-	mock               *UserRepositoryMock
-	defaultExpectation *UserRepositoryMockGetExpectation
-	expectations       []*UserRepositoryMockGetExpectation
-
-	callArgs []*UserRepositoryMockGetParams
-	mutex    sync.RWMutex
-}
-
-// UserRepositoryMockGetExpectation specifies expectation struct of the UserRepository.Get
-type UserRepositoryMockGetExpectation struct {
-	mock    *UserRepositoryMock
-	params  *UserRepositoryMockGetParams
-	results *UserRepositoryMockGetResults
-	Counter uint64
-}
-
-// UserRepositoryMockGetParams contains parameters of the UserRepository.Get
-type UserRepositoryMockGetParams struct {
-	ctx      context.Context
-	username string
-}
-
-// UserRepositoryMockGetResults contains results of the UserRepository.Get
-type UserRepositoryMockGetResults struct {
-	up1 *models.User
-	err error
-}
-
-// Expect sets up expected params for UserRepository.Get
-func (mmGet *mUserRepositoryMockGet) Expect(ctx context.Context, username string) *mUserRepositoryMockGet {
-	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
-	}
-
-	if mmGet.defaultExpectation == nil {
-		mmGet.defaultExpectation = &UserRepositoryMockGetExpectation{}
-	}
-
-	mmGet.defaultExpectation.params = &UserRepositoryMockGetParams{ctx, username}
-	for _, e := range mmGet.expectations {
-		if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
-			mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
-		}
-	}
-
-	return mmGet
-}
-
-// Inspect accepts an inspector function that has same arguments as the UserRepository.Get
-func (mmGet *mUserRepositoryMockGet) Inspect(f func(ctx context.Context, username string)) *mUserRepositoryMockGet {
-	if mmGet.mock.inspectFuncGet != nil {
-		mmGet.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.Get")
-	}
-
-	mmGet.mock.inspectFuncGet = f
-
-	return mmGet
-}
-
-// Return sets up results that will be returned by UserRepository.Get
-func (mmGet *mUserRepositoryMockGet) Return(up1 *models.User, err error) *UserRepositoryMock {
-	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
-	}
-
-	if mmGet.defaultExpectation == nil {
-		mmGet.defaultExpectation = &UserRepositoryMockGetExpectation{mock: mmGet.mock}
-	}
-	mmGet.defaultExpectation.results = &UserRepositoryMockGetResults{up1, err}
-	return mmGet.mock
-}
-
-// Set uses given function f to mock the UserRepository.Get method
-func (mmGet *mUserRepositoryMockGet) Set(f func(ctx context.Context, username string) (up1 *models.User, err error)) *UserRepositoryMock {
-	if mmGet.defaultExpectation != nil {
-		mmGet.mock.t.Fatalf("Default expectation is already set for the UserRepository.Get method")
-	}
-
-	if len(mmGet.expectations) > 0 {
-		mmGet.mock.t.Fatalf("Some expectations are already set for the UserRepository.Get method")
-	}
-
-	mmGet.mock.funcGet = f
-	return mmGet.mock
-}
-
-// When sets expectation for the UserRepository.Get which will trigger the result defined by the following
-// Then helper
-func (mmGet *mUserRepositoryMockGet) When(ctx context.Context, username string) *UserRepositoryMockGetExpectation {
-	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("UserRepositoryMock.Get mock is already set by Set")
-	}
-
-	expectation := &UserRepositoryMockGetExpectation{
-		mock:   mmGet.mock,
-		params: &UserRepositoryMockGetParams{ctx, username},
-	}
-	mmGet.expectations = append(mmGet.expectations, expectation)
-	return expectation
-}
-
-// Then sets up UserRepository.Get return parameters for the expectation previously defined by the When method
-func (e *UserRepositoryMockGetExpectation) Then(up1 *models.User, err error) *UserRepositoryMock {
-	e.results = &UserRepositoryMockGetResults{up1, err}
-	return e.mock
-}
-
-// Get implements interfaces.UserRepository
-func (mmGet *UserRepositoryMock) Get(ctx context.Context, username string) (up1 *models.User, err error) {
-	mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
-	defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
-
-	if mmGet.inspectFuncGet != nil {
-		mmGet.inspectFuncGet(ctx, username)
-	}
-
-	mm_params := &UserRepositoryMockGetParams{ctx, username}
-
-	// Record call args
-	mmGet.GetMock.mutex.Lock()
-	mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, mm_params)
-	mmGet.GetMock.mutex.Unlock()
-
-	for _, e := range mmGet.GetMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.up1, e.results.err
-		}
-	}
-
-	if mmGet.GetMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
-		mm_want := mmGet.GetMock.defaultExpectation.params
-		mm_got := UserRepositoryMockGetParams{ctx, username}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGet.t.Errorf("UserRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGet.GetMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGet.t.Fatal("No results are set for the UserRepositoryMock.Get")
-		}
-		return (*mm_results).up1, (*mm_results).err
-	}
-	if mmGet.funcGet != nil {
-		return mmGet.funcGet(ctx, username)
-	}
-	mmGet.t.Fatalf("Unexpected call to UserRepositoryMock.Get. %v %v", ctx, username)
-	return
-}
-
-// GetAfterCounter returns a count of finished UserRepositoryMock.Get invocations
-func (mmGet *UserRepositoryMock) GetAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
-}
-
-// GetBeforeCounter returns a count of UserRepositoryMock.Get invocations
-func (mmGet *UserRepositoryMock) GetBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
-}
-
-// Calls returns a list of arguments used in each call to UserRepositoryMock.Get.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGet *mUserRepositoryMockGet) Calls() []*UserRepositoryMockGetParams {
-	mmGet.mutex.RLock()
-
-	argCopy := make([]*UserRepositoryMockGetParams, len(mmGet.callArgs))
-	copy(argCopy, mmGet.callArgs)
-
-	mmGet.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetDone returns true if the count of the Get invocations corresponds
-// the number of defined expectations
-func (m *UserRepositoryMock) MinimockGetDone() bool {
-	for _, e := range m.GetMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetInspect logs each unmet expectation
-func (m *UserRepositoryMock) MinimockGetInspect() {
-	for _, e := range m.GetMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to UserRepositoryMock.Get with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		if m.GetMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to UserRepositoryMock.Get")
-		} else {
-			m.t.Errorf("Expected call to UserRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		m.t.Error("Expected call to UserRepositoryMock.Get")
-	}
-}
-
-// MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *UserRepositoryMock) MinimockFinish() {
-	if !m.minimockDone() {
-		m.MinimockAddInspect()
-
-		m.MinimockGetInspect()
-		m.t.FailNow()
-	}
-}
-
-// MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *UserRepositoryMock) MinimockWait(timeout mm_time.Duration) {
-	timeoutCh := mm_time.After(timeout)
-	for {
-		if m.minimockDone() {
-			return
-		}
-		select {
-		case <-timeoutCh:
-			m.MinimockFinish()
-			return
-		case <-mm_time.After(10 * mm_time.Millisecond):
-		}
-	}
-}
-
-func (m *UserRepositoryMock) minimockDone() bool {
-	done := true
-	return done &&
-		m.MinimockAddDone() &&
-		m.MinimockGetDone()
-}

+ 14 - 18
internal/repositories/tag.go

@@ -1,29 +1,25 @@
 package repositories
 
-//go:generate mkdir -p mocks
-//go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.TagRepository -o ./mocks/ -s "_minimock.go"
-
 import (
 	"context"
 	"database/sql"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 	sq "github.com/Masterminds/squirrel"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 )
 
 const tagTableName = "tag"
 
-type tagRepository struct {
+type TagRepository struct {
 	db *sql.DB
 }
 
-func InitTagRepository(db *sql.DB) interfaces.TagRepository {
-	return tagRepository{db: db}
+func InitTagRepository(db *sql.DB) *TagRepository {
+	return &TagRepository{db: db}
 }
 
-func (t tagRepository) GetAllUsed(ctx context.Context) ([]models.Tag, error) {
+func (t TagRepository) GetAllUsed(ctx context.Context) ([]models.Tag, error) {
 	var res []models.Tag
 
 	query := "SELECT t.id, t.url, t.tag " +
@@ -56,7 +52,7 @@ func (t tagRepository) GetAllUsed(ctx context.Context) ([]models.Tag, error) {
 	return res, nil
 }
 
-func (t tagRepository) GetByURL(ctx context.Context, url string) (*models.Tag, error) {
+func (t TagRepository) GetByURL(ctx context.Context, url string) (*models.Tag, error) {
 	query, args, err := sq.Select("id", "url", "tag").
 		From(tagTableName).
 		PlaceholderFormat(sq.Dollar).
@@ -80,7 +76,7 @@ func (t tagRepository) GetByURL(ctx context.Context, url string) (*models.Tag, e
 	return &res, nil
 }
 
-func (t tagRepository) GetByID(ctx context.Context, id int) (*models.Tag, error) {
+func (t TagRepository) GetByID(ctx context.Context, id int) (*models.Tag, error) {
 	query, args, err := sq.Select("id", "url", "tag").
 		From(tagTableName).
 		PlaceholderFormat(sq.Dollar).
@@ -104,7 +100,7 @@ func (t tagRepository) GetByID(ctx context.Context, id int) (*models.Tag, error)
 	return &res, nil
 }
 
-func (t tagRepository) GetAll(ctx context.Context) ([]models.Tag, error) {
+func (t TagRepository) GetAll(ctx context.Context) ([]models.Tag, error) {
 	var res []models.Tag
 
 	query, args, err := sq.Select("id", "url", "tag").
@@ -139,7 +135,7 @@ func (t tagRepository) GetAll(ctx context.Context) ([]models.Tag, error) {
 	return res, nil
 }
 
-func (t tagRepository) GetByArticleID(ctx context.Context, id int) ([]models.Tag, error) {
+func (t TagRepository) GetByArticleID(ctx context.Context, id int) ([]models.Tag, error) {
 	var res []models.Tag
 
 	query := "SELECT t.id, t.url, t.tag " +
@@ -170,7 +166,7 @@ func (t tagRepository) GetByArticleID(ctx context.Context, id int) ([]models.Tag
 	return res, nil
 }
 
-func (t tagRepository) IsUsed(ctx context.Context, id int) (bool, error) {
+func (t TagRepository) IsUsed(ctx context.Context, id int) (bool, error) {
 	query, args, err := sq.Select("COUNT(tag_id)").
 		From(articleTagTableName).
 		PlaceholderFormat(sq.Dollar).
@@ -190,7 +186,7 @@ func (t tagRepository) IsUsed(ctx context.Context, id int) (bool, error) {
 	return count > 0, nil
 }
 
-func (t tagRepository) Add(ctx context.Context, req models.Tag) error {
+func (t TagRepository) Add(ctx context.Context, req models.Tag) error {
 	query, args, err := sq.Insert(tagTableName).
 		PlaceholderFormat(sq.Dollar).
 		Columns("tag", "url").
@@ -206,7 +202,7 @@ func (t tagRepository) Add(ctx context.Context, req models.Tag) error {
 	return err
 }
 
-func (t tagRepository) Update(ctx context.Context, req models.Tag) error {
+func (t TagRepository) Update(ctx context.Context, req models.Tag) error {
 	query, args, err := sq.Update(tagTableName).
 		PlaceholderFormat(sq.Dollar).
 		Set("tag", req.Tag).
@@ -223,7 +219,7 @@ func (t tagRepository) Update(ctx context.Context, req models.Tag) error {
 	return err
 }
 
-func (t tagRepository) Delete(ctx context.Context, id int) error {
+func (t TagRepository) Delete(ctx context.Context, id int) error {
 	query, args, err := sq.Delete(tagTableName).
 		PlaceholderFormat(sq.Dollar).
 		Where(sq.Eq{"id": id}).

+ 8 - 12
internal/repositories/user.go

@@ -1,31 +1,27 @@
 package repositories
 
-//go:generate mkdir -p mocks
-//go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.UserRepository -o ./mocks/ -s "_minimock.go"
-
 import (
 	"context"
 	"database/sql"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 	sq "github.com/Masterminds/squirrel"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 )
 
 const (
 	userTableName = "\"user\""
 )
 
-type userRepository struct {
+type UserRepository struct {
 	db *sql.DB
 }
 
-func InitUserRepository(db *sql.DB) interfaces.UserRepository {
-	return userRepository{db: db}
+func InitUserRepository(db *sql.DB) *UserRepository {
+	return &UserRepository{db: db}
 }
 
-func (u userRepository) Get(ctx context.Context, username string) (*models.User, error) {
+func (u UserRepository) Get(ctx context.Context, username string) (*models.User, error) {
 	query, args, err := sq.Select("id", "username", "password", "created_at", "updated_at").
 		From(userTableName).
 		PlaceholderFormat(sq.Dollar).
@@ -47,7 +43,7 @@ func (u userRepository) Get(ctx context.Context, username string) (*models.User,
 	return &res, nil
 }
 
-func (u userRepository) Add(ctx context.Context, username string, password string) (int, error) {
+func (u UserRepository) Add(ctx context.Context, username string, password string) (int, error) {
 	query, args, err := sq.Insert(userTableName).
 		PlaceholderFormat(sq.Dollar).
 		Columns("username", "password").
@@ -67,7 +63,7 @@ func (u userRepository) Add(ctx context.Context, username string, password strin
 	return id, nil
 }
 
-func (u userRepository) UpdatePassword(ctx context.Context, id int, newPassword string) error {
+func (u UserRepository) UpdatePassword(ctx context.Context, id int, newPassword string) error {
 	query, args, err := sq.Update(userTableName).
 		PlaceholderFormat(sq.Dollar).
 		Set("password", newPassword).

+ 17 - 45
internal/service_provider/sp.go

@@ -1,7 +1,6 @@
 package sp
 
 import (
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/repositories"
 	authService "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/auth"
 	cacheService "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/cache"
@@ -11,17 +10,17 @@ import (
 )
 
 type ServiceProvider struct {
-	env                  interfaces.Env
-	cache                interfaces.Cache
-	mailer               interfaces.Mailer
-	auth                 interfaces.Auth
-	articleRepository    interfaces.ArticleRepository
-	tagRepository        interfaces.TagRepository
-	articleTagRepository interfaces.ArticleTagRepository
-	userRepository       interfaces.UserRepository
+	env                  *envService.Service
+	cache                *cacheService.Service
+	mailer               *mailService.Service
+	auth                 *authService.Service
+	articleRepository    *repositories.ArticleRepository
+	tagRepository        *repositories.TagRepository
+	articleTagRepository *repositories.ArticleTagRepository
+	userRepository       *repositories.UserRepository
 }
 
-func Init() (interfaces.ServiceProvider, error) {
+func Init() (*ServiceProvider, error) {
 	sp := &ServiceProvider{}
 
 	// Init services
@@ -63,61 +62,34 @@ func Init() (interfaces.ServiceProvider, error) {
 	return sp, nil
 }
 
-func (sp *ServiceProvider) GetEnvService() interfaces.Env {
+func (sp *ServiceProvider) EnvService() *envService.Service {
 	return sp.env
 }
 
-func (sp *ServiceProvider) GetCacheService() interfaces.Cache {
+func (sp *ServiceProvider) CacheService() *cacheService.Service {
 	return sp.cache
 }
 
-func (sp *ServiceProvider) GetMailerService() interfaces.Mailer {
+func (sp *ServiceProvider) MailerService() *mailService.Service {
 	return sp.mailer
 }
 
-func (sp *ServiceProvider) GetAuthService() interfaces.Auth {
+func (sp *ServiceProvider) AuthService() *authService.Service {
 	return sp.auth
 }
 
-func (sp *ServiceProvider) GetArticleRepository() interfaces.ArticleRepository {
+func (sp *ServiceProvider) ArticleRepository() *repositories.ArticleRepository {
 	return sp.articleRepository
 }
 
-func (sp *ServiceProvider) GetTagRepository() interfaces.TagRepository {
+func (sp *ServiceProvider) TagRepository() *repositories.TagRepository {
 	return sp.tagRepository
 }
 
-func (sp *ServiceProvider) GetArticleTagRepository() interfaces.ArticleTagRepository {
+func (sp *ServiceProvider) ArticleTagRepository() *repositories.ArticleTagRepository {
 	return sp.articleTagRepository
 }
 
-func (sp *ServiceProvider) GetUserRepository() interfaces.UserRepository {
+func (sp *ServiceProvider) UserRepository() *repositories.UserRepository {
 	return sp.userRepository
 }
-
-func InitMock(deps ...interface{}) interfaces.ServiceProvider {
-	sp := ServiceProvider{}
-
-	for _, d := range deps {
-		switch s := d.(type) {
-		case interfaces.Cache:
-			sp.cache = s
-		case interfaces.Auth:
-			sp.auth = s
-		case interfaces.Env:
-			sp.env = s
-		case interfaces.Mailer:
-			sp.mailer = s
-		case interfaces.ArticleRepository:
-			sp.articleRepository = s
-		case interfaces.ArticleTagRepository:
-			sp.articleTagRepository = s
-		case interfaces.TagRepository:
-			sp.tagRepository = s
-		case interfaces.UserRepository:
-			sp.userRepository = s
-		}
-	}
-
-	return &sp
-}

+ 23 - 20
internal/services/auth/auth.go

@@ -1,33 +1,36 @@
 package auth
 
-//go:generate mkdir -p mocks
-//go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i ../../interfaces.Auth -o ./mocks/ -s "_minimock.go"
-
 import (
 	"time"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 	"github.com/gofiber/fiber/v2"
 	"github.com/golang-jwt/jwt/v4"
 	"golang.org/x/crypto/bcrypt"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 )
 
 const (
-	defaultCost    = bcrypt.DefaultCost
-	defaultUserKey = "user"
+	ClaimNameKey = "name"
+	claimUserKey = "user"
+	claimExpKey  = "exp"
+	defaultCost  = bcrypt.DefaultCost
 )
 
-type auth struct {
-	env interfaces.Env
+type Env interface {
+	JWTSecretKey() string
+	JWTLifetime() int
+}
+
+type Service struct {
+	env Env
 }
 
-func Init(env interfaces.Env) (interfaces.Auth, error) {
-	return auth{env: env}, nil
+func Init(env Env) (*Service, error) {
+	return &Service{env: env}, nil
 }
 
-func (a auth) GeneratePasswordHash(password string) (string, error) {
+func (a Service) GeneratePasswordHash(password string) (string, error) {
 	res, err := bcrypt.GenerateFromPassword([]byte(password), defaultCost)
 	if err != nil {
 		return "", err
@@ -36,24 +39,24 @@ func (a auth) GeneratePasswordHash(password string) (string, error) {
 	return string(res), nil
 }
 
-func (a auth) IsCorrectPassword(password string, hash string) bool {
+func (a Service) IsCorrectPassword(password string, hash string) bool {
 	return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) == nil
 }
 
-func (a auth) GetClaims(fctx *fiber.Ctx) jwt.MapClaims {
-	jwtUser := fctx.Locals(defaultUserKey).(*jwt.Token)
+func (a Service) GetClaims(fctx *fiber.Ctx) jwt.MapClaims {
+	jwtUser := fctx.Locals(claimUserKey).(*jwt.Token)
 	claims := jwtUser.Claims.(jwt.MapClaims)
 
 	return claims
 }
 
-func (a auth) GenerateToken(user models.User) (string, error) {
+func (a Service) GenerateToken(user models.User) (string, error) {
 	claims := jwt.MapClaims{
-		"name": user.Username,
-		"exp":  time.Now().Add(time.Duration(a.env.GetJWTLifetime()) * time.Second).Unix(),
+		ClaimNameKey: user.Username,
+		claimExpKey:  time.Now().Add(time.Duration(a.env.JWTLifetime()) * time.Second).Unix(),
 	}
 
 	token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
 
-	return token.SignedString([]byte(a.env.GetJWTSecretKey()))
+	return token.SignedString([]byte(a.env.JWTSecretKey()))
 }

+ 0 - 969
internal/services/auth/mocks/auth_minimock.go

@@ -1,969 +0,0 @@
-package mocks
-
-// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
-
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.Auth -o ./mocks/auth_minimock.go -n AuthMock
-
-import (
-	"sync"
-	mm_atomic "sync/atomic"
-	mm_time "time"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	"github.com/gofiber/fiber/v2"
-	"github.com/gojuno/minimock/v3"
-	"github.com/golang-jwt/jwt/v4"
-)
-
-// AuthMock implements interfaces.Auth
-type AuthMock struct {
-	t minimock.Tester
-
-	funcGeneratePasswordHash          func(password string) (s1 string, err error)
-	inspectFuncGeneratePasswordHash   func(password string)
-	afterGeneratePasswordHashCounter  uint64
-	beforeGeneratePasswordHashCounter uint64
-	GeneratePasswordHashMock          mAuthMockGeneratePasswordHash
-
-	funcGenerateToken          func(user models.User) (s1 string, err error)
-	inspectFuncGenerateToken   func(user models.User)
-	afterGenerateTokenCounter  uint64
-	beforeGenerateTokenCounter uint64
-	GenerateTokenMock          mAuthMockGenerateToken
-
-	funcGetClaims          func(fctx *fiber.Ctx) (m1 jwt.MapClaims)
-	inspectFuncGetClaims   func(fctx *fiber.Ctx)
-	afterGetClaimsCounter  uint64
-	beforeGetClaimsCounter uint64
-	GetClaimsMock          mAuthMockGetClaims
-
-	funcIsCorrectPassword          func(password string, hash string) (b1 bool)
-	inspectFuncIsCorrectPassword   func(password string, hash string)
-	afterIsCorrectPasswordCounter  uint64
-	beforeIsCorrectPasswordCounter uint64
-	IsCorrectPasswordMock          mAuthMockIsCorrectPassword
-}
-
-// NewAuthMock returns a mock for interfaces.Auth
-func NewAuthMock(t minimock.Tester) *AuthMock {
-	m := &AuthMock{t: t}
-	if controller, ok := t.(minimock.MockController); ok {
-		controller.RegisterMocker(m)
-	}
-
-	m.GeneratePasswordHashMock = mAuthMockGeneratePasswordHash{mock: m}
-	m.GeneratePasswordHashMock.callArgs = []*AuthMockGeneratePasswordHashParams{}
-
-	m.GenerateTokenMock = mAuthMockGenerateToken{mock: m}
-	m.GenerateTokenMock.callArgs = []*AuthMockGenerateTokenParams{}
-
-	m.GetClaimsMock = mAuthMockGetClaims{mock: m}
-	m.GetClaimsMock.callArgs = []*AuthMockGetClaimsParams{}
-
-	m.IsCorrectPasswordMock = mAuthMockIsCorrectPassword{mock: m}
-	m.IsCorrectPasswordMock.callArgs = []*AuthMockIsCorrectPasswordParams{}
-
-	return m
-}
-
-type mAuthMockGeneratePasswordHash struct {
-	mock               *AuthMock
-	defaultExpectation *AuthMockGeneratePasswordHashExpectation
-	expectations       []*AuthMockGeneratePasswordHashExpectation
-
-	callArgs []*AuthMockGeneratePasswordHashParams
-	mutex    sync.RWMutex
-}
-
-// AuthMockGeneratePasswordHashExpectation specifies expectation struct of the Auth.GeneratePasswordHash
-type AuthMockGeneratePasswordHashExpectation struct {
-	mock    *AuthMock
-	params  *AuthMockGeneratePasswordHashParams
-	results *AuthMockGeneratePasswordHashResults
-	Counter uint64
-}
-
-// AuthMockGeneratePasswordHashParams contains parameters of the Auth.GeneratePasswordHash
-type AuthMockGeneratePasswordHashParams struct {
-	password string
-}
-
-// AuthMockGeneratePasswordHashResults contains results of the Auth.GeneratePasswordHash
-type AuthMockGeneratePasswordHashResults struct {
-	s1  string
-	err error
-}
-
-// Expect sets up expected params for Auth.GeneratePasswordHash
-func (mmGeneratePasswordHash *mAuthMockGeneratePasswordHash) Expect(password string) *mAuthMockGeneratePasswordHash {
-	if mmGeneratePasswordHash.mock.funcGeneratePasswordHash != nil {
-		mmGeneratePasswordHash.mock.t.Fatalf("AuthMock.GeneratePasswordHash mock is already set by Set")
-	}
-
-	if mmGeneratePasswordHash.defaultExpectation == nil {
-		mmGeneratePasswordHash.defaultExpectation = &AuthMockGeneratePasswordHashExpectation{}
-	}
-
-	mmGeneratePasswordHash.defaultExpectation.params = &AuthMockGeneratePasswordHashParams{password}
-	for _, e := range mmGeneratePasswordHash.expectations {
-		if minimock.Equal(e.params, mmGeneratePasswordHash.defaultExpectation.params) {
-			mmGeneratePasswordHash.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGeneratePasswordHash.defaultExpectation.params)
-		}
-	}
-
-	return mmGeneratePasswordHash
-}
-
-// Inspect accepts an inspector function that has same arguments as the Auth.GeneratePasswordHash
-func (mmGeneratePasswordHash *mAuthMockGeneratePasswordHash) Inspect(f func(password string)) *mAuthMockGeneratePasswordHash {
-	if mmGeneratePasswordHash.mock.inspectFuncGeneratePasswordHash != nil {
-		mmGeneratePasswordHash.mock.t.Fatalf("Inspect function is already set for AuthMock.GeneratePasswordHash")
-	}
-
-	mmGeneratePasswordHash.mock.inspectFuncGeneratePasswordHash = f
-
-	return mmGeneratePasswordHash
-}
-
-// Return sets up results that will be returned by Auth.GeneratePasswordHash
-func (mmGeneratePasswordHash *mAuthMockGeneratePasswordHash) Return(s1 string, err error) *AuthMock {
-	if mmGeneratePasswordHash.mock.funcGeneratePasswordHash != nil {
-		mmGeneratePasswordHash.mock.t.Fatalf("AuthMock.GeneratePasswordHash mock is already set by Set")
-	}
-
-	if mmGeneratePasswordHash.defaultExpectation == nil {
-		mmGeneratePasswordHash.defaultExpectation = &AuthMockGeneratePasswordHashExpectation{mock: mmGeneratePasswordHash.mock}
-	}
-	mmGeneratePasswordHash.defaultExpectation.results = &AuthMockGeneratePasswordHashResults{s1, err}
-	return mmGeneratePasswordHash.mock
-}
-
-// Set uses given function f to mock the Auth.GeneratePasswordHash method
-func (mmGeneratePasswordHash *mAuthMockGeneratePasswordHash) Set(f func(password string) (s1 string, err error)) *AuthMock {
-	if mmGeneratePasswordHash.defaultExpectation != nil {
-		mmGeneratePasswordHash.mock.t.Fatalf("Default expectation is already set for the Auth.GeneratePasswordHash method")
-	}
-
-	if len(mmGeneratePasswordHash.expectations) > 0 {
-		mmGeneratePasswordHash.mock.t.Fatalf("Some expectations are already set for the Auth.GeneratePasswordHash method")
-	}
-
-	mmGeneratePasswordHash.mock.funcGeneratePasswordHash = f
-	return mmGeneratePasswordHash.mock
-}
-
-// When sets expectation for the Auth.GeneratePasswordHash which will trigger the result defined by the following
-// Then helper
-func (mmGeneratePasswordHash *mAuthMockGeneratePasswordHash) When(password string) *AuthMockGeneratePasswordHashExpectation {
-	if mmGeneratePasswordHash.mock.funcGeneratePasswordHash != nil {
-		mmGeneratePasswordHash.mock.t.Fatalf("AuthMock.GeneratePasswordHash mock is already set by Set")
-	}
-
-	expectation := &AuthMockGeneratePasswordHashExpectation{
-		mock:   mmGeneratePasswordHash.mock,
-		params: &AuthMockGeneratePasswordHashParams{password},
-	}
-	mmGeneratePasswordHash.expectations = append(mmGeneratePasswordHash.expectations, expectation)
-	return expectation
-}
-
-// Then sets up Auth.GeneratePasswordHash return parameters for the expectation previously defined by the When method
-func (e *AuthMockGeneratePasswordHashExpectation) Then(s1 string, err error) *AuthMock {
-	e.results = &AuthMockGeneratePasswordHashResults{s1, err}
-	return e.mock
-}
-
-// GeneratePasswordHash implements interfaces.Auth
-func (mmGeneratePasswordHash *AuthMock) GeneratePasswordHash(password string) (s1 string, err error) {
-	mm_atomic.AddUint64(&mmGeneratePasswordHash.beforeGeneratePasswordHashCounter, 1)
-	defer mm_atomic.AddUint64(&mmGeneratePasswordHash.afterGeneratePasswordHashCounter, 1)
-
-	if mmGeneratePasswordHash.inspectFuncGeneratePasswordHash != nil {
-		mmGeneratePasswordHash.inspectFuncGeneratePasswordHash(password)
-	}
-
-	mm_params := &AuthMockGeneratePasswordHashParams{password}
-
-	// Record call args
-	mmGeneratePasswordHash.GeneratePasswordHashMock.mutex.Lock()
-	mmGeneratePasswordHash.GeneratePasswordHashMock.callArgs = append(mmGeneratePasswordHash.GeneratePasswordHashMock.callArgs, mm_params)
-	mmGeneratePasswordHash.GeneratePasswordHashMock.mutex.Unlock()
-
-	for _, e := range mmGeneratePasswordHash.GeneratePasswordHashMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.s1, e.results.err
-		}
-	}
-
-	if mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation.Counter, 1)
-		mm_want := mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation.params
-		mm_got := AuthMockGeneratePasswordHashParams{password}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGeneratePasswordHash.t.Errorf("AuthMock.GeneratePasswordHash got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGeneratePasswordHash.GeneratePasswordHashMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGeneratePasswordHash.t.Fatal("No results are set for the AuthMock.GeneratePasswordHash")
-		}
-		return (*mm_results).s1, (*mm_results).err
-	}
-	if mmGeneratePasswordHash.funcGeneratePasswordHash != nil {
-		return mmGeneratePasswordHash.funcGeneratePasswordHash(password)
-	}
-	mmGeneratePasswordHash.t.Fatalf("Unexpected call to AuthMock.GeneratePasswordHash. %v", password)
-	return
-}
-
-// GeneratePasswordHashAfterCounter returns a count of finished AuthMock.GeneratePasswordHash invocations
-func (mmGeneratePasswordHash *AuthMock) GeneratePasswordHashAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGeneratePasswordHash.afterGeneratePasswordHashCounter)
-}
-
-// GeneratePasswordHashBeforeCounter returns a count of AuthMock.GeneratePasswordHash invocations
-func (mmGeneratePasswordHash *AuthMock) GeneratePasswordHashBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGeneratePasswordHash.beforeGeneratePasswordHashCounter)
-}
-
-// Calls returns a list of arguments used in each call to AuthMock.GeneratePasswordHash.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGeneratePasswordHash *mAuthMockGeneratePasswordHash) Calls() []*AuthMockGeneratePasswordHashParams {
-	mmGeneratePasswordHash.mutex.RLock()
-
-	argCopy := make([]*AuthMockGeneratePasswordHashParams, len(mmGeneratePasswordHash.callArgs))
-	copy(argCopy, mmGeneratePasswordHash.callArgs)
-
-	mmGeneratePasswordHash.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGeneratePasswordHashDone returns true if the count of the GeneratePasswordHash invocations corresponds
-// the number of defined expectations
-func (m *AuthMock) MinimockGeneratePasswordHashDone() bool {
-	for _, e := range m.GeneratePasswordHashMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GeneratePasswordHashMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGeneratePasswordHashCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGeneratePasswordHash != nil && mm_atomic.LoadUint64(&m.afterGeneratePasswordHashCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGeneratePasswordHashInspect logs each unmet expectation
-func (m *AuthMock) MinimockGeneratePasswordHashInspect() {
-	for _, e := range m.GeneratePasswordHashMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to AuthMock.GeneratePasswordHash with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GeneratePasswordHashMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGeneratePasswordHashCounter) < 1 {
-		if m.GeneratePasswordHashMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to AuthMock.GeneratePasswordHash")
-		} else {
-			m.t.Errorf("Expected call to AuthMock.GeneratePasswordHash with params: %#v", *m.GeneratePasswordHashMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGeneratePasswordHash != nil && mm_atomic.LoadUint64(&m.afterGeneratePasswordHashCounter) < 1 {
-		m.t.Error("Expected call to AuthMock.GeneratePasswordHash")
-	}
-}
-
-type mAuthMockGenerateToken struct {
-	mock               *AuthMock
-	defaultExpectation *AuthMockGenerateTokenExpectation
-	expectations       []*AuthMockGenerateTokenExpectation
-
-	callArgs []*AuthMockGenerateTokenParams
-	mutex    sync.RWMutex
-}
-
-// AuthMockGenerateTokenExpectation specifies expectation struct of the Auth.GenerateToken
-type AuthMockGenerateTokenExpectation struct {
-	mock    *AuthMock
-	params  *AuthMockGenerateTokenParams
-	results *AuthMockGenerateTokenResults
-	Counter uint64
-}
-
-// AuthMockGenerateTokenParams contains parameters of the Auth.GenerateToken
-type AuthMockGenerateTokenParams struct {
-	user models.User
-}
-
-// AuthMockGenerateTokenResults contains results of the Auth.GenerateToken
-type AuthMockGenerateTokenResults struct {
-	s1  string
-	err error
-}
-
-// Expect sets up expected params for Auth.GenerateToken
-func (mmGenerateToken *mAuthMockGenerateToken) Expect(user models.User) *mAuthMockGenerateToken {
-	if mmGenerateToken.mock.funcGenerateToken != nil {
-		mmGenerateToken.mock.t.Fatalf("AuthMock.GenerateToken mock is already set by Set")
-	}
-
-	if mmGenerateToken.defaultExpectation == nil {
-		mmGenerateToken.defaultExpectation = &AuthMockGenerateTokenExpectation{}
-	}
-
-	mmGenerateToken.defaultExpectation.params = &AuthMockGenerateTokenParams{user}
-	for _, e := range mmGenerateToken.expectations {
-		if minimock.Equal(e.params, mmGenerateToken.defaultExpectation.params) {
-			mmGenerateToken.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGenerateToken.defaultExpectation.params)
-		}
-	}
-
-	return mmGenerateToken
-}
-
-// Inspect accepts an inspector function that has same arguments as the Auth.GenerateToken
-func (mmGenerateToken *mAuthMockGenerateToken) Inspect(f func(user models.User)) *mAuthMockGenerateToken {
-	if mmGenerateToken.mock.inspectFuncGenerateToken != nil {
-		mmGenerateToken.mock.t.Fatalf("Inspect function is already set for AuthMock.GenerateToken")
-	}
-
-	mmGenerateToken.mock.inspectFuncGenerateToken = f
-
-	return mmGenerateToken
-}
-
-// Return sets up results that will be returned by Auth.GenerateToken
-func (mmGenerateToken *mAuthMockGenerateToken) Return(s1 string, err error) *AuthMock {
-	if mmGenerateToken.mock.funcGenerateToken != nil {
-		mmGenerateToken.mock.t.Fatalf("AuthMock.GenerateToken mock is already set by Set")
-	}
-
-	if mmGenerateToken.defaultExpectation == nil {
-		mmGenerateToken.defaultExpectation = &AuthMockGenerateTokenExpectation{mock: mmGenerateToken.mock}
-	}
-	mmGenerateToken.defaultExpectation.results = &AuthMockGenerateTokenResults{s1, err}
-	return mmGenerateToken.mock
-}
-
-// Set uses given function f to mock the Auth.GenerateToken method
-func (mmGenerateToken *mAuthMockGenerateToken) Set(f func(user models.User) (s1 string, err error)) *AuthMock {
-	if mmGenerateToken.defaultExpectation != nil {
-		mmGenerateToken.mock.t.Fatalf("Default expectation is already set for the Auth.GenerateToken method")
-	}
-
-	if len(mmGenerateToken.expectations) > 0 {
-		mmGenerateToken.mock.t.Fatalf("Some expectations are already set for the Auth.GenerateToken method")
-	}
-
-	mmGenerateToken.mock.funcGenerateToken = f
-	return mmGenerateToken.mock
-}
-
-// When sets expectation for the Auth.GenerateToken which will trigger the result defined by the following
-// Then helper
-func (mmGenerateToken *mAuthMockGenerateToken) When(user models.User) *AuthMockGenerateTokenExpectation {
-	if mmGenerateToken.mock.funcGenerateToken != nil {
-		mmGenerateToken.mock.t.Fatalf("AuthMock.GenerateToken mock is already set by Set")
-	}
-
-	expectation := &AuthMockGenerateTokenExpectation{
-		mock:   mmGenerateToken.mock,
-		params: &AuthMockGenerateTokenParams{user},
-	}
-	mmGenerateToken.expectations = append(mmGenerateToken.expectations, expectation)
-	return expectation
-}
-
-// Then sets up Auth.GenerateToken return parameters for the expectation previously defined by the When method
-func (e *AuthMockGenerateTokenExpectation) Then(s1 string, err error) *AuthMock {
-	e.results = &AuthMockGenerateTokenResults{s1, err}
-	return e.mock
-}
-
-// GenerateToken implements interfaces.Auth
-func (mmGenerateToken *AuthMock) GenerateToken(user models.User) (s1 string, err error) {
-	mm_atomic.AddUint64(&mmGenerateToken.beforeGenerateTokenCounter, 1)
-	defer mm_atomic.AddUint64(&mmGenerateToken.afterGenerateTokenCounter, 1)
-
-	if mmGenerateToken.inspectFuncGenerateToken != nil {
-		mmGenerateToken.inspectFuncGenerateToken(user)
-	}
-
-	mm_params := &AuthMockGenerateTokenParams{user}
-
-	// Record call args
-	mmGenerateToken.GenerateTokenMock.mutex.Lock()
-	mmGenerateToken.GenerateTokenMock.callArgs = append(mmGenerateToken.GenerateTokenMock.callArgs, mm_params)
-	mmGenerateToken.GenerateTokenMock.mutex.Unlock()
-
-	for _, e := range mmGenerateToken.GenerateTokenMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.s1, e.results.err
-		}
-	}
-
-	if mmGenerateToken.GenerateTokenMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGenerateToken.GenerateTokenMock.defaultExpectation.Counter, 1)
-		mm_want := mmGenerateToken.GenerateTokenMock.defaultExpectation.params
-		mm_got := AuthMockGenerateTokenParams{user}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGenerateToken.t.Errorf("AuthMock.GenerateToken got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGenerateToken.GenerateTokenMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGenerateToken.t.Fatal("No results are set for the AuthMock.GenerateToken")
-		}
-		return (*mm_results).s1, (*mm_results).err
-	}
-	if mmGenerateToken.funcGenerateToken != nil {
-		return mmGenerateToken.funcGenerateToken(user)
-	}
-	mmGenerateToken.t.Fatalf("Unexpected call to AuthMock.GenerateToken. %v", user)
-	return
-}
-
-// GenerateTokenAfterCounter returns a count of finished AuthMock.GenerateToken invocations
-func (mmGenerateToken *AuthMock) GenerateTokenAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGenerateToken.afterGenerateTokenCounter)
-}
-
-// GenerateTokenBeforeCounter returns a count of AuthMock.GenerateToken invocations
-func (mmGenerateToken *AuthMock) GenerateTokenBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGenerateToken.beforeGenerateTokenCounter)
-}
-
-// Calls returns a list of arguments used in each call to AuthMock.GenerateToken.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGenerateToken *mAuthMockGenerateToken) Calls() []*AuthMockGenerateTokenParams {
-	mmGenerateToken.mutex.RLock()
-
-	argCopy := make([]*AuthMockGenerateTokenParams, len(mmGenerateToken.callArgs))
-	copy(argCopy, mmGenerateToken.callArgs)
-
-	mmGenerateToken.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGenerateTokenDone returns true if the count of the GenerateToken invocations corresponds
-// the number of defined expectations
-func (m *AuthMock) MinimockGenerateTokenDone() bool {
-	for _, e := range m.GenerateTokenMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GenerateTokenMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGenerateTokenCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGenerateToken != nil && mm_atomic.LoadUint64(&m.afterGenerateTokenCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGenerateTokenInspect logs each unmet expectation
-func (m *AuthMock) MinimockGenerateTokenInspect() {
-	for _, e := range m.GenerateTokenMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to AuthMock.GenerateToken with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GenerateTokenMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGenerateTokenCounter) < 1 {
-		if m.GenerateTokenMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to AuthMock.GenerateToken")
-		} else {
-			m.t.Errorf("Expected call to AuthMock.GenerateToken with params: %#v", *m.GenerateTokenMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGenerateToken != nil && mm_atomic.LoadUint64(&m.afterGenerateTokenCounter) < 1 {
-		m.t.Error("Expected call to AuthMock.GenerateToken")
-	}
-}
-
-type mAuthMockGetClaims struct {
-	mock               *AuthMock
-	defaultExpectation *AuthMockGetClaimsExpectation
-	expectations       []*AuthMockGetClaimsExpectation
-
-	callArgs []*AuthMockGetClaimsParams
-	mutex    sync.RWMutex
-}
-
-// AuthMockGetClaimsExpectation specifies expectation struct of the Auth.GetClaims
-type AuthMockGetClaimsExpectation struct {
-	mock    *AuthMock
-	params  *AuthMockGetClaimsParams
-	results *AuthMockGetClaimsResults
-	Counter uint64
-}
-
-// AuthMockGetClaimsParams contains parameters of the Auth.GetClaims
-type AuthMockGetClaimsParams struct {
-	fctx *fiber.Ctx
-}
-
-// AuthMockGetClaimsResults contains results of the Auth.GetClaims
-type AuthMockGetClaimsResults struct {
-	m1 jwt.MapClaims
-}
-
-// Expect sets up expected params for Auth.GetClaims
-func (mmGetClaims *mAuthMockGetClaims) Expect(fctx *fiber.Ctx) *mAuthMockGetClaims {
-	if mmGetClaims.mock.funcGetClaims != nil {
-		mmGetClaims.mock.t.Fatalf("AuthMock.GetClaims mock is already set by Set")
-	}
-
-	if mmGetClaims.defaultExpectation == nil {
-		mmGetClaims.defaultExpectation = &AuthMockGetClaimsExpectation{}
-	}
-
-	mmGetClaims.defaultExpectation.params = &AuthMockGetClaimsParams{fctx}
-	for _, e := range mmGetClaims.expectations {
-		if minimock.Equal(e.params, mmGetClaims.defaultExpectation.params) {
-			mmGetClaims.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetClaims.defaultExpectation.params)
-		}
-	}
-
-	return mmGetClaims
-}
-
-// Inspect accepts an inspector function that has same arguments as the Auth.GetClaims
-func (mmGetClaims *mAuthMockGetClaims) Inspect(f func(fctx *fiber.Ctx)) *mAuthMockGetClaims {
-	if mmGetClaims.mock.inspectFuncGetClaims != nil {
-		mmGetClaims.mock.t.Fatalf("Inspect function is already set for AuthMock.GetClaims")
-	}
-
-	mmGetClaims.mock.inspectFuncGetClaims = f
-
-	return mmGetClaims
-}
-
-// Return sets up results that will be returned by Auth.GetClaims
-func (mmGetClaims *mAuthMockGetClaims) Return(m1 jwt.MapClaims) *AuthMock {
-	if mmGetClaims.mock.funcGetClaims != nil {
-		mmGetClaims.mock.t.Fatalf("AuthMock.GetClaims mock is already set by Set")
-	}
-
-	if mmGetClaims.defaultExpectation == nil {
-		mmGetClaims.defaultExpectation = &AuthMockGetClaimsExpectation{mock: mmGetClaims.mock}
-	}
-	mmGetClaims.defaultExpectation.results = &AuthMockGetClaimsResults{m1}
-	return mmGetClaims.mock
-}
-
-// Set uses given function f to mock the Auth.GetClaims method
-func (mmGetClaims *mAuthMockGetClaims) Set(f func(fctx *fiber.Ctx) (m1 jwt.MapClaims)) *AuthMock {
-	if mmGetClaims.defaultExpectation != nil {
-		mmGetClaims.mock.t.Fatalf("Default expectation is already set for the Auth.GetClaims method")
-	}
-
-	if len(mmGetClaims.expectations) > 0 {
-		mmGetClaims.mock.t.Fatalf("Some expectations are already set for the Auth.GetClaims method")
-	}
-
-	mmGetClaims.mock.funcGetClaims = f
-	return mmGetClaims.mock
-}
-
-// When sets expectation for the Auth.GetClaims which will trigger the result defined by the following
-// Then helper
-func (mmGetClaims *mAuthMockGetClaims) When(fctx *fiber.Ctx) *AuthMockGetClaimsExpectation {
-	if mmGetClaims.mock.funcGetClaims != nil {
-		mmGetClaims.mock.t.Fatalf("AuthMock.GetClaims mock is already set by Set")
-	}
-
-	expectation := &AuthMockGetClaimsExpectation{
-		mock:   mmGetClaims.mock,
-		params: &AuthMockGetClaimsParams{fctx},
-	}
-	mmGetClaims.expectations = append(mmGetClaims.expectations, expectation)
-	return expectation
-}
-
-// Then sets up Auth.GetClaims return parameters for the expectation previously defined by the When method
-func (e *AuthMockGetClaimsExpectation) Then(m1 jwt.MapClaims) *AuthMock {
-	e.results = &AuthMockGetClaimsResults{m1}
-	return e.mock
-}
-
-// GetClaims implements interfaces.Auth
-func (mmGetClaims *AuthMock) GetClaims(fctx *fiber.Ctx) (m1 jwt.MapClaims) {
-	mm_atomic.AddUint64(&mmGetClaims.beforeGetClaimsCounter, 1)
-	defer mm_atomic.AddUint64(&mmGetClaims.afterGetClaimsCounter, 1)
-
-	if mmGetClaims.inspectFuncGetClaims != nil {
-		mmGetClaims.inspectFuncGetClaims(fctx)
-	}
-
-	mm_params := &AuthMockGetClaimsParams{fctx}
-
-	// Record call args
-	mmGetClaims.GetClaimsMock.mutex.Lock()
-	mmGetClaims.GetClaimsMock.callArgs = append(mmGetClaims.GetClaimsMock.callArgs, mm_params)
-	mmGetClaims.GetClaimsMock.mutex.Unlock()
-
-	for _, e := range mmGetClaims.GetClaimsMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.m1
-		}
-	}
-
-	if mmGetClaims.GetClaimsMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGetClaims.GetClaimsMock.defaultExpectation.Counter, 1)
-		mm_want := mmGetClaims.GetClaimsMock.defaultExpectation.params
-		mm_got := AuthMockGetClaimsParams{fctx}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGetClaims.t.Errorf("AuthMock.GetClaims got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGetClaims.GetClaimsMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGetClaims.t.Fatal("No results are set for the AuthMock.GetClaims")
-		}
-		return (*mm_results).m1
-	}
-	if mmGetClaims.funcGetClaims != nil {
-		return mmGetClaims.funcGetClaims(fctx)
-	}
-	mmGetClaims.t.Fatalf("Unexpected call to AuthMock.GetClaims. %v", fctx)
-	return
-}
-
-// GetClaimsAfterCounter returns a count of finished AuthMock.GetClaims invocations
-func (mmGetClaims *AuthMock) GetClaimsAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetClaims.afterGetClaimsCounter)
-}
-
-// GetClaimsBeforeCounter returns a count of AuthMock.GetClaims invocations
-func (mmGetClaims *AuthMock) GetClaimsBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGetClaims.beforeGetClaimsCounter)
-}
-
-// Calls returns a list of arguments used in each call to AuthMock.GetClaims.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGetClaims *mAuthMockGetClaims) Calls() []*AuthMockGetClaimsParams {
-	mmGetClaims.mutex.RLock()
-
-	argCopy := make([]*AuthMockGetClaimsParams, len(mmGetClaims.callArgs))
-	copy(argCopy, mmGetClaims.callArgs)
-
-	mmGetClaims.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetClaimsDone returns true if the count of the GetClaims invocations corresponds
-// the number of defined expectations
-func (m *AuthMock) MinimockGetClaimsDone() bool {
-	for _, e := range m.GetClaimsMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetClaimsMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetClaimsCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetClaims != nil && mm_atomic.LoadUint64(&m.afterGetClaimsCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetClaimsInspect logs each unmet expectation
-func (m *AuthMock) MinimockGetClaimsInspect() {
-	for _, e := range m.GetClaimsMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to AuthMock.GetClaims with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetClaimsMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetClaimsCounter) < 1 {
-		if m.GetClaimsMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to AuthMock.GetClaims")
-		} else {
-			m.t.Errorf("Expected call to AuthMock.GetClaims with params: %#v", *m.GetClaimsMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGetClaims != nil && mm_atomic.LoadUint64(&m.afterGetClaimsCounter) < 1 {
-		m.t.Error("Expected call to AuthMock.GetClaims")
-	}
-}
-
-type mAuthMockIsCorrectPassword struct {
-	mock               *AuthMock
-	defaultExpectation *AuthMockIsCorrectPasswordExpectation
-	expectations       []*AuthMockIsCorrectPasswordExpectation
-
-	callArgs []*AuthMockIsCorrectPasswordParams
-	mutex    sync.RWMutex
-}
-
-// AuthMockIsCorrectPasswordExpectation specifies expectation struct of the Auth.IsCorrectPassword
-type AuthMockIsCorrectPasswordExpectation struct {
-	mock    *AuthMock
-	params  *AuthMockIsCorrectPasswordParams
-	results *AuthMockIsCorrectPasswordResults
-	Counter uint64
-}
-
-// AuthMockIsCorrectPasswordParams contains parameters of the Auth.IsCorrectPassword
-type AuthMockIsCorrectPasswordParams struct {
-	password string
-	hash     string
-}
-
-// AuthMockIsCorrectPasswordResults contains results of the Auth.IsCorrectPassword
-type AuthMockIsCorrectPasswordResults struct {
-	b1 bool
-}
-
-// Expect sets up expected params for Auth.IsCorrectPassword
-func (mmIsCorrectPassword *mAuthMockIsCorrectPassword) Expect(password string, hash string) *mAuthMockIsCorrectPassword {
-	if mmIsCorrectPassword.mock.funcIsCorrectPassword != nil {
-		mmIsCorrectPassword.mock.t.Fatalf("AuthMock.IsCorrectPassword mock is already set by Set")
-	}
-
-	if mmIsCorrectPassword.defaultExpectation == nil {
-		mmIsCorrectPassword.defaultExpectation = &AuthMockIsCorrectPasswordExpectation{}
-	}
-
-	mmIsCorrectPassword.defaultExpectation.params = &AuthMockIsCorrectPasswordParams{password, hash}
-	for _, e := range mmIsCorrectPassword.expectations {
-		if minimock.Equal(e.params, mmIsCorrectPassword.defaultExpectation.params) {
-			mmIsCorrectPassword.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIsCorrectPassword.defaultExpectation.params)
-		}
-	}
-
-	return mmIsCorrectPassword
-}
-
-// Inspect accepts an inspector function that has same arguments as the Auth.IsCorrectPassword
-func (mmIsCorrectPassword *mAuthMockIsCorrectPassword) Inspect(f func(password string, hash string)) *mAuthMockIsCorrectPassword {
-	if mmIsCorrectPassword.mock.inspectFuncIsCorrectPassword != nil {
-		mmIsCorrectPassword.mock.t.Fatalf("Inspect function is already set for AuthMock.IsCorrectPassword")
-	}
-
-	mmIsCorrectPassword.mock.inspectFuncIsCorrectPassword = f
-
-	return mmIsCorrectPassword
-}
-
-// Return sets up results that will be returned by Auth.IsCorrectPassword
-func (mmIsCorrectPassword *mAuthMockIsCorrectPassword) Return(b1 bool) *AuthMock {
-	if mmIsCorrectPassword.mock.funcIsCorrectPassword != nil {
-		mmIsCorrectPassword.mock.t.Fatalf("AuthMock.IsCorrectPassword mock is already set by Set")
-	}
-
-	if mmIsCorrectPassword.defaultExpectation == nil {
-		mmIsCorrectPassword.defaultExpectation = &AuthMockIsCorrectPasswordExpectation{mock: mmIsCorrectPassword.mock}
-	}
-	mmIsCorrectPassword.defaultExpectation.results = &AuthMockIsCorrectPasswordResults{b1}
-	return mmIsCorrectPassword.mock
-}
-
-// Set uses given function f to mock the Auth.IsCorrectPassword method
-func (mmIsCorrectPassword *mAuthMockIsCorrectPassword) Set(f func(password string, hash string) (b1 bool)) *AuthMock {
-	if mmIsCorrectPassword.defaultExpectation != nil {
-		mmIsCorrectPassword.mock.t.Fatalf("Default expectation is already set for the Auth.IsCorrectPassword method")
-	}
-
-	if len(mmIsCorrectPassword.expectations) > 0 {
-		mmIsCorrectPassword.mock.t.Fatalf("Some expectations are already set for the Auth.IsCorrectPassword method")
-	}
-
-	mmIsCorrectPassword.mock.funcIsCorrectPassword = f
-	return mmIsCorrectPassword.mock
-}
-
-// When sets expectation for the Auth.IsCorrectPassword which will trigger the result defined by the following
-// Then helper
-func (mmIsCorrectPassword *mAuthMockIsCorrectPassword) When(password string, hash string) *AuthMockIsCorrectPasswordExpectation {
-	if mmIsCorrectPassword.mock.funcIsCorrectPassword != nil {
-		mmIsCorrectPassword.mock.t.Fatalf("AuthMock.IsCorrectPassword mock is already set by Set")
-	}
-
-	expectation := &AuthMockIsCorrectPasswordExpectation{
-		mock:   mmIsCorrectPassword.mock,
-		params: &AuthMockIsCorrectPasswordParams{password, hash},
-	}
-	mmIsCorrectPassword.expectations = append(mmIsCorrectPassword.expectations, expectation)
-	return expectation
-}
-
-// Then sets up Auth.IsCorrectPassword return parameters for the expectation previously defined by the When method
-func (e *AuthMockIsCorrectPasswordExpectation) Then(b1 bool) *AuthMock {
-	e.results = &AuthMockIsCorrectPasswordResults{b1}
-	return e.mock
-}
-
-// IsCorrectPassword implements interfaces.Auth
-func (mmIsCorrectPassword *AuthMock) IsCorrectPassword(password string, hash string) (b1 bool) {
-	mm_atomic.AddUint64(&mmIsCorrectPassword.beforeIsCorrectPasswordCounter, 1)
-	defer mm_atomic.AddUint64(&mmIsCorrectPassword.afterIsCorrectPasswordCounter, 1)
-
-	if mmIsCorrectPassword.inspectFuncIsCorrectPassword != nil {
-		mmIsCorrectPassword.inspectFuncIsCorrectPassword(password, hash)
-	}
-
-	mm_params := &AuthMockIsCorrectPasswordParams{password, hash}
-
-	// Record call args
-	mmIsCorrectPassword.IsCorrectPasswordMock.mutex.Lock()
-	mmIsCorrectPassword.IsCorrectPasswordMock.callArgs = append(mmIsCorrectPassword.IsCorrectPasswordMock.callArgs, mm_params)
-	mmIsCorrectPassword.IsCorrectPasswordMock.mutex.Unlock()
-
-	for _, e := range mmIsCorrectPassword.IsCorrectPasswordMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.b1
-		}
-	}
-
-	if mmIsCorrectPassword.IsCorrectPasswordMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmIsCorrectPassword.IsCorrectPasswordMock.defaultExpectation.Counter, 1)
-		mm_want := mmIsCorrectPassword.IsCorrectPasswordMock.defaultExpectation.params
-		mm_got := AuthMockIsCorrectPasswordParams{password, hash}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmIsCorrectPassword.t.Errorf("AuthMock.IsCorrectPassword got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmIsCorrectPassword.IsCorrectPasswordMock.defaultExpectation.results
-		if mm_results == nil {
-			mmIsCorrectPassword.t.Fatal("No results are set for the AuthMock.IsCorrectPassword")
-		}
-		return (*mm_results).b1
-	}
-	if mmIsCorrectPassword.funcIsCorrectPassword != nil {
-		return mmIsCorrectPassword.funcIsCorrectPassword(password, hash)
-	}
-	mmIsCorrectPassword.t.Fatalf("Unexpected call to AuthMock.IsCorrectPassword. %v %v", password, hash)
-	return
-}
-
-// IsCorrectPasswordAfterCounter returns a count of finished AuthMock.IsCorrectPassword invocations
-func (mmIsCorrectPassword *AuthMock) IsCorrectPasswordAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmIsCorrectPassword.afterIsCorrectPasswordCounter)
-}
-
-// IsCorrectPasswordBeforeCounter returns a count of AuthMock.IsCorrectPassword invocations
-func (mmIsCorrectPassword *AuthMock) IsCorrectPasswordBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmIsCorrectPassword.beforeIsCorrectPasswordCounter)
-}
-
-// Calls returns a list of arguments used in each call to AuthMock.IsCorrectPassword.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmIsCorrectPassword *mAuthMockIsCorrectPassword) Calls() []*AuthMockIsCorrectPasswordParams {
-	mmIsCorrectPassword.mutex.RLock()
-
-	argCopy := make([]*AuthMockIsCorrectPasswordParams, len(mmIsCorrectPassword.callArgs))
-	copy(argCopy, mmIsCorrectPassword.callArgs)
-
-	mmIsCorrectPassword.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockIsCorrectPasswordDone returns true if the count of the IsCorrectPassword invocations corresponds
-// the number of defined expectations
-func (m *AuthMock) MinimockIsCorrectPasswordDone() bool {
-	for _, e := range m.IsCorrectPasswordMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.IsCorrectPasswordMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsCorrectPasswordCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcIsCorrectPassword != nil && mm_atomic.LoadUint64(&m.afterIsCorrectPasswordCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockIsCorrectPasswordInspect logs each unmet expectation
-func (m *AuthMock) MinimockIsCorrectPasswordInspect() {
-	for _, e := range m.IsCorrectPasswordMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to AuthMock.IsCorrectPassword with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.IsCorrectPasswordMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsCorrectPasswordCounter) < 1 {
-		if m.IsCorrectPasswordMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to AuthMock.IsCorrectPassword")
-		} else {
-			m.t.Errorf("Expected call to AuthMock.IsCorrectPassword with params: %#v", *m.IsCorrectPasswordMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcIsCorrectPassword != nil && mm_atomic.LoadUint64(&m.afterIsCorrectPasswordCounter) < 1 {
-		m.t.Error("Expected call to AuthMock.IsCorrectPassword")
-	}
-}
-
-// MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *AuthMock) MinimockFinish() {
-	if !m.minimockDone() {
-		m.MinimockGeneratePasswordHashInspect()
-
-		m.MinimockGenerateTokenInspect()
-
-		m.MinimockGetClaimsInspect()
-
-		m.MinimockIsCorrectPasswordInspect()
-		m.t.FailNow()
-	}
-}
-
-// MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *AuthMock) MinimockWait(timeout mm_time.Duration) {
-	timeoutCh := mm_time.After(timeout)
-	for {
-		if m.minimockDone() {
-			return
-		}
-		select {
-		case <-timeoutCh:
-			m.MinimockFinish()
-			return
-		case <-mm_time.After(10 * mm_time.Millisecond):
-		}
-	}
-}
-
-func (m *AuthMock) minimockDone() bool {
-	done := true
-	return done &&
-		m.MinimockGeneratePasswordHashDone() &&
-		m.MinimockGenerateTokenDone() &&
-		m.MinimockGetClaimsDone() &&
-		m.MinimockIsCorrectPasswordDone()
-}

+ 6 - 12
internal/services/cache/cache.go

@@ -1,27 +1,21 @@
 package cache
 
-//go:generate mkdir -p mocks
-//go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i ../../interfaces.Cache -o ./mocks/ -s "_minimock.go"
-
 import (
 	"sync"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
 )
 
-type cache struct {
+type Service struct {
 	data map[string]interface{}
 	sync.RWMutex
 }
 
-func Init() (interfaces.Cache, error) {
-	return &cache{
+func Init() (*Service, error) {
+	return &Service{
 		data: make(map[string]interface{}),
 	}, nil
 }
 
-func (c *cache) Get(key string) (interface{}, bool) {
+func (c *Service) Get(key string) (interface{}, bool) {
 	c.RLock()
 	defer c.RUnlock()
 
@@ -33,14 +27,14 @@ func (c *cache) Get(key string) (interface{}, bool) {
 	return res, true
 }
 
-func (c *cache) Set(key string, value interface{}) {
+func (c *Service) Set(key string, value interface{}) {
 	c.Lock()
 	defer c.Unlock()
 
 	c.data[key] = value
 }
 
-func (c *cache) FlushAll() {
+func (c *Service) FlushAll() {
 	c.Lock()
 	defer c.Unlock()
 

+ 0 - 629
internal/services/cache/mocks/cache_minimock.go

@@ -1,629 +0,0 @@
-package mocks
-
-// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
-
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.Cache -o ./mocks/cache_minimock.go -n CacheMock
-
-import (
-	"sync"
-	mm_atomic "sync/atomic"
-	mm_time "time"
-
-	"github.com/gojuno/minimock/v3"
-)
-
-// CacheMock implements interfaces.Cache
-type CacheMock struct {
-	t minimock.Tester
-
-	funcFlushAll          func()
-	inspectFuncFlushAll   func()
-	afterFlushAllCounter  uint64
-	beforeFlushAllCounter uint64
-	FlushAllMock          mCacheMockFlushAll
-
-	funcGet          func(key string) (p1 interface{}, b1 bool)
-	inspectFuncGet   func(key string)
-	afterGetCounter  uint64
-	beforeGetCounter uint64
-	GetMock          mCacheMockGet
-
-	funcSet          func(key string, value interface{})
-	inspectFuncSet   func(key string, value interface{})
-	afterSetCounter  uint64
-	beforeSetCounter uint64
-	SetMock          mCacheMockSet
-}
-
-// NewCacheMock returns a mock for interfaces.Cache
-func NewCacheMock(t minimock.Tester) *CacheMock {
-	m := &CacheMock{t: t}
-	if controller, ok := t.(minimock.MockController); ok {
-		controller.RegisterMocker(m)
-	}
-
-	m.FlushAllMock = mCacheMockFlushAll{mock: m}
-
-	m.GetMock = mCacheMockGet{mock: m}
-	m.GetMock.callArgs = []*CacheMockGetParams{}
-
-	m.SetMock = mCacheMockSet{mock: m}
-	m.SetMock.callArgs = []*CacheMockSetParams{}
-
-	return m
-}
-
-type mCacheMockFlushAll struct {
-	mock               *CacheMock
-	defaultExpectation *CacheMockFlushAllExpectation
-	expectations       []*CacheMockFlushAllExpectation
-}
-
-// CacheMockFlushAllExpectation specifies expectation struct of the Cache.FlushAll
-type CacheMockFlushAllExpectation struct {
-	mock *CacheMock
-
-	Counter uint64
-}
-
-// Expect sets up expected params for Cache.FlushAll
-func (mmFlushAll *mCacheMockFlushAll) Expect() *mCacheMockFlushAll {
-	if mmFlushAll.mock.funcFlushAll != nil {
-		mmFlushAll.mock.t.Fatalf("CacheMock.FlushAll mock is already set by Set")
-	}
-
-	if mmFlushAll.defaultExpectation == nil {
-		mmFlushAll.defaultExpectation = &CacheMockFlushAllExpectation{}
-	}
-
-	return mmFlushAll
-}
-
-// Inspect accepts an inspector function that has same arguments as the Cache.FlushAll
-func (mmFlushAll *mCacheMockFlushAll) Inspect(f func()) *mCacheMockFlushAll {
-	if mmFlushAll.mock.inspectFuncFlushAll != nil {
-		mmFlushAll.mock.t.Fatalf("Inspect function is already set for CacheMock.FlushAll")
-	}
-
-	mmFlushAll.mock.inspectFuncFlushAll = f
-
-	return mmFlushAll
-}
-
-// Return sets up results that will be returned by Cache.FlushAll
-func (mmFlushAll *mCacheMockFlushAll) Return() *CacheMock {
-	if mmFlushAll.mock.funcFlushAll != nil {
-		mmFlushAll.mock.t.Fatalf("CacheMock.FlushAll mock is already set by Set")
-	}
-
-	if mmFlushAll.defaultExpectation == nil {
-		mmFlushAll.defaultExpectation = &CacheMockFlushAllExpectation{mock: mmFlushAll.mock}
-	}
-
-	return mmFlushAll.mock
-}
-
-// Set uses given function f to mock the Cache.FlushAll method
-func (mmFlushAll *mCacheMockFlushAll) Set(f func()) *CacheMock {
-	if mmFlushAll.defaultExpectation != nil {
-		mmFlushAll.mock.t.Fatalf("Default expectation is already set for the Cache.FlushAll method")
-	}
-
-	if len(mmFlushAll.expectations) > 0 {
-		mmFlushAll.mock.t.Fatalf("Some expectations are already set for the Cache.FlushAll method")
-	}
-
-	mmFlushAll.mock.funcFlushAll = f
-	return mmFlushAll.mock
-}
-
-// FlushAll implements interfaces.Cache
-func (mmFlushAll *CacheMock) FlushAll() {
-	mm_atomic.AddUint64(&mmFlushAll.beforeFlushAllCounter, 1)
-	defer mm_atomic.AddUint64(&mmFlushAll.afterFlushAllCounter, 1)
-
-	if mmFlushAll.inspectFuncFlushAll != nil {
-		mmFlushAll.inspectFuncFlushAll()
-	}
-
-	if mmFlushAll.FlushAllMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmFlushAll.FlushAllMock.defaultExpectation.Counter, 1)
-
-		return
-
-	}
-	if mmFlushAll.funcFlushAll != nil {
-		mmFlushAll.funcFlushAll()
-		return
-	}
-	mmFlushAll.t.Fatalf("Unexpected call to CacheMock.FlushAll.")
-
-}
-
-// FlushAllAfterCounter returns a count of finished CacheMock.FlushAll invocations
-func (mmFlushAll *CacheMock) FlushAllAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmFlushAll.afterFlushAllCounter)
-}
-
-// FlushAllBeforeCounter returns a count of CacheMock.FlushAll invocations
-func (mmFlushAll *CacheMock) FlushAllBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmFlushAll.beforeFlushAllCounter)
-}
-
-// MinimockFlushAllDone returns true if the count of the FlushAll invocations corresponds
-// the number of defined expectations
-func (m *CacheMock) MinimockFlushAllDone() bool {
-	for _, e := range m.FlushAllMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.FlushAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcFlushAll != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockFlushAllInspect logs each unmet expectation
-func (m *CacheMock) MinimockFlushAllInspect() {
-	for _, e := range m.FlushAllMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Error("Expected call to CacheMock.FlushAll")
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.FlushAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
-		m.t.Error("Expected call to CacheMock.FlushAll")
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcFlushAll != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
-		m.t.Error("Expected call to CacheMock.FlushAll")
-	}
-}
-
-type mCacheMockGet struct {
-	mock               *CacheMock
-	defaultExpectation *CacheMockGetExpectation
-	expectations       []*CacheMockGetExpectation
-
-	callArgs []*CacheMockGetParams
-	mutex    sync.RWMutex
-}
-
-// CacheMockGetExpectation specifies expectation struct of the Cache.Get
-type CacheMockGetExpectation struct {
-	mock    *CacheMock
-	params  *CacheMockGetParams
-	results *CacheMockGetResults
-	Counter uint64
-}
-
-// CacheMockGetParams contains parameters of the Cache.Get
-type CacheMockGetParams struct {
-	key string
-}
-
-// CacheMockGetResults contains results of the Cache.Get
-type CacheMockGetResults struct {
-	p1 interface{}
-	b1 bool
-}
-
-// Expect sets up expected params for Cache.Get
-func (mmGet *mCacheMockGet) Expect(key string) *mCacheMockGet {
-	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
-	}
-
-	if mmGet.defaultExpectation == nil {
-		mmGet.defaultExpectation = &CacheMockGetExpectation{}
-	}
-
-	mmGet.defaultExpectation.params = &CacheMockGetParams{key}
-	for _, e := range mmGet.expectations {
-		if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
-			mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
-		}
-	}
-
-	return mmGet
-}
-
-// Inspect accepts an inspector function that has same arguments as the Cache.Get
-func (mmGet *mCacheMockGet) Inspect(f func(key string)) *mCacheMockGet {
-	if mmGet.mock.inspectFuncGet != nil {
-		mmGet.mock.t.Fatalf("Inspect function is already set for CacheMock.Get")
-	}
-
-	mmGet.mock.inspectFuncGet = f
-
-	return mmGet
-}
-
-// Return sets up results that will be returned by Cache.Get
-func (mmGet *mCacheMockGet) Return(p1 interface{}, b1 bool) *CacheMock {
-	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
-	}
-
-	if mmGet.defaultExpectation == nil {
-		mmGet.defaultExpectation = &CacheMockGetExpectation{mock: mmGet.mock}
-	}
-	mmGet.defaultExpectation.results = &CacheMockGetResults{p1, b1}
-	return mmGet.mock
-}
-
-// Set uses given function f to mock the Cache.Get method
-func (mmGet *mCacheMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *CacheMock {
-	if mmGet.defaultExpectation != nil {
-		mmGet.mock.t.Fatalf("Default expectation is already set for the Cache.Get method")
-	}
-
-	if len(mmGet.expectations) > 0 {
-		mmGet.mock.t.Fatalf("Some expectations are already set for the Cache.Get method")
-	}
-
-	mmGet.mock.funcGet = f
-	return mmGet.mock
-}
-
-// When sets expectation for the Cache.Get which will trigger the result defined by the following
-// Then helper
-func (mmGet *mCacheMockGet) When(key string) *CacheMockGetExpectation {
-	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
-	}
-
-	expectation := &CacheMockGetExpectation{
-		mock:   mmGet.mock,
-		params: &CacheMockGetParams{key},
-	}
-	mmGet.expectations = append(mmGet.expectations, expectation)
-	return expectation
-}
-
-// Then sets up Cache.Get return parameters for the expectation previously defined by the When method
-func (e *CacheMockGetExpectation) Then(p1 interface{}, b1 bool) *CacheMock {
-	e.results = &CacheMockGetResults{p1, b1}
-	return e.mock
-}
-
-// Get implements interfaces.Cache
-func (mmGet *CacheMock) Get(key string) (p1 interface{}, b1 bool) {
-	mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
-	defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
-
-	if mmGet.inspectFuncGet != nil {
-		mmGet.inspectFuncGet(key)
-	}
-
-	mm_params := &CacheMockGetParams{key}
-
-	// Record call args
-	mmGet.GetMock.mutex.Lock()
-	mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, mm_params)
-	mmGet.GetMock.mutex.Unlock()
-
-	for _, e := range mmGet.GetMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.p1, e.results.b1
-		}
-	}
-
-	if mmGet.GetMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
-		mm_want := mmGet.GetMock.defaultExpectation.params
-		mm_got := CacheMockGetParams{key}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGet.t.Errorf("CacheMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmGet.GetMock.defaultExpectation.results
-		if mm_results == nil {
-			mmGet.t.Fatal("No results are set for the CacheMock.Get")
-		}
-		return (*mm_results).p1, (*mm_results).b1
-	}
-	if mmGet.funcGet != nil {
-		return mmGet.funcGet(key)
-	}
-	mmGet.t.Fatalf("Unexpected call to CacheMock.Get. %v", key)
-	return
-}
-
-// GetAfterCounter returns a count of finished CacheMock.Get invocations
-func (mmGet *CacheMock) GetAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
-}
-
-// GetBeforeCounter returns a count of CacheMock.Get invocations
-func (mmGet *CacheMock) GetBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
-}
-
-// Calls returns a list of arguments used in each call to CacheMock.Get.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGet *mCacheMockGet) Calls() []*CacheMockGetParams {
-	mmGet.mutex.RLock()
-
-	argCopy := make([]*CacheMockGetParams, len(mmGet.callArgs))
-	copy(argCopy, mmGet.callArgs)
-
-	mmGet.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockGetDone returns true if the count of the Get invocations corresponds
-// the number of defined expectations
-func (m *CacheMock) MinimockGetDone() bool {
-	for _, e := range m.GetMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockGetInspect logs each unmet expectation
-func (m *CacheMock) MinimockGetInspect() {
-	for _, e := range m.GetMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to CacheMock.Get with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		if m.GetMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to CacheMock.Get")
-		} else {
-			m.t.Errorf("Expected call to CacheMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		m.t.Error("Expected call to CacheMock.Get")
-	}
-}
-
-type mCacheMockSet struct {
-	mock               *CacheMock
-	defaultExpectation *CacheMockSetExpectation
-	expectations       []*CacheMockSetExpectation
-
-	callArgs []*CacheMockSetParams
-	mutex    sync.RWMutex
-}
-
-// CacheMockSetExpectation specifies expectation struct of the Cache.Set
-type CacheMockSetExpectation struct {
-	mock   *CacheMock
-	params *CacheMockSetParams
-
-	Counter uint64
-}
-
-// CacheMockSetParams contains parameters of the Cache.Set
-type CacheMockSetParams struct {
-	key   string
-	value interface{}
-}
-
-// Expect sets up expected params for Cache.Set
-func (mmSet *mCacheMockSet) Expect(key string, value interface{}) *mCacheMockSet {
-	if mmSet.mock.funcSet != nil {
-		mmSet.mock.t.Fatalf("CacheMock.Set mock is already set by Set")
-	}
-
-	if mmSet.defaultExpectation == nil {
-		mmSet.defaultExpectation = &CacheMockSetExpectation{}
-	}
-
-	mmSet.defaultExpectation.params = &CacheMockSetParams{key, value}
-	for _, e := range mmSet.expectations {
-		if minimock.Equal(e.params, mmSet.defaultExpectation.params) {
-			mmSet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSet.defaultExpectation.params)
-		}
-	}
-
-	return mmSet
-}
-
-// Inspect accepts an inspector function that has same arguments as the Cache.Set
-func (mmSet *mCacheMockSet) Inspect(f func(key string, value interface{})) *mCacheMockSet {
-	if mmSet.mock.inspectFuncSet != nil {
-		mmSet.mock.t.Fatalf("Inspect function is already set for CacheMock.Set")
-	}
-
-	mmSet.mock.inspectFuncSet = f
-
-	return mmSet
-}
-
-// Return sets up results that will be returned by Cache.Set
-func (mmSet *mCacheMockSet) Return() *CacheMock {
-	if mmSet.mock.funcSet != nil {
-		mmSet.mock.t.Fatalf("CacheMock.Set mock is already set by Set")
-	}
-
-	if mmSet.defaultExpectation == nil {
-		mmSet.defaultExpectation = &CacheMockSetExpectation{mock: mmSet.mock}
-	}
-
-	return mmSet.mock
-}
-
-// Set uses given function f to mock the Cache.Set method
-func (mmSet *mCacheMockSet) Set(f func(key string, value interface{})) *CacheMock {
-	if mmSet.defaultExpectation != nil {
-		mmSet.mock.t.Fatalf("Default expectation is already set for the Cache.Set method")
-	}
-
-	if len(mmSet.expectations) > 0 {
-		mmSet.mock.t.Fatalf("Some expectations are already set for the Cache.Set method")
-	}
-
-	mmSet.mock.funcSet = f
-	return mmSet.mock
-}
-
-// Set implements interfaces.Cache
-func (mmSet *CacheMock) Set(key string, value interface{}) {
-	mm_atomic.AddUint64(&mmSet.beforeSetCounter, 1)
-	defer mm_atomic.AddUint64(&mmSet.afterSetCounter, 1)
-
-	if mmSet.inspectFuncSet != nil {
-		mmSet.inspectFuncSet(key, value)
-	}
-
-	mm_params := &CacheMockSetParams{key, value}
-
-	// Record call args
-	mmSet.SetMock.mutex.Lock()
-	mmSet.SetMock.callArgs = append(mmSet.SetMock.callArgs, mm_params)
-	mmSet.SetMock.mutex.Unlock()
-
-	for _, e := range mmSet.SetMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return
-		}
-	}
-
-	if mmSet.SetMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmSet.SetMock.defaultExpectation.Counter, 1)
-		mm_want := mmSet.SetMock.defaultExpectation.params
-		mm_got := CacheMockSetParams{key, value}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmSet.t.Errorf("CacheMock.Set got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		return
-
-	}
-	if mmSet.funcSet != nil {
-		mmSet.funcSet(key, value)
-		return
-	}
-	mmSet.t.Fatalf("Unexpected call to CacheMock.Set. %v %v", key, value)
-
-}
-
-// SetAfterCounter returns a count of finished CacheMock.Set invocations
-func (mmSet *CacheMock) SetAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmSet.afterSetCounter)
-}
-
-// SetBeforeCounter returns a count of CacheMock.Set invocations
-func (mmSet *CacheMock) SetBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmSet.beforeSetCounter)
-}
-
-// Calls returns a list of arguments used in each call to CacheMock.Set.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmSet *mCacheMockSet) Calls() []*CacheMockSetParams {
-	mmSet.mutex.RLock()
-
-	argCopy := make([]*CacheMockSetParams, len(mmSet.callArgs))
-	copy(argCopy, mmSet.callArgs)
-
-	mmSet.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockSetDone returns true if the count of the Set invocations corresponds
-// the number of defined expectations
-func (m *CacheMock) MinimockSetDone() bool {
-	for _, e := range m.SetMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.SetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcSet != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockSetInspect logs each unmet expectation
-func (m *CacheMock) MinimockSetInspect() {
-	for _, e := range m.SetMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to CacheMock.Set with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.SetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
-		if m.SetMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to CacheMock.Set")
-		} else {
-			m.t.Errorf("Expected call to CacheMock.Set with params: %#v", *m.SetMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcSet != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
-		m.t.Error("Expected call to CacheMock.Set")
-	}
-}
-
-// MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *CacheMock) MinimockFinish() {
-	if !m.minimockDone() {
-		m.MinimockFlushAllInspect()
-
-		m.MinimockGetInspect()
-
-		m.MinimockSetInspect()
-		m.t.FailNow()
-	}
-}
-
-// MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *CacheMock) MinimockWait(timeout mm_time.Duration) {
-	timeoutCh := mm_time.After(timeout)
-	for {
-		if m.minimockDone() {
-			return
-		}
-		select {
-		case <-timeoutCh:
-			m.MinimockFinish()
-			return
-		case <-mm_time.After(10 * mm_time.Millisecond):
-		}
-	}
-}
-
-func (m *CacheMock) minimockDone() bool {
-	done := true
-	return done &&
-		m.MinimockFlushAllDone() &&
-		m.MinimockGetDone() &&
-		m.MinimockSetDone()
-}

+ 27 - 16
internal/services/db/db.go

@@ -3,16 +3,27 @@ package db
 import (
 	"database/sql"
 	"time"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
 )
 
-func Init(env interfaces.Env) (*sql.DB, error) {
-	dataSource := "user=" + env.GetDBUser() +
-		" password=" + env.GetDBPassword() +
-		" dbname=" + env.GetDBName() +
-		" host=" + env.GetDBHost() +
-		" port=" + env.GetDBPort() +
+type Env interface {
+	AppPort() string
+	DBHost() string
+	DBPort() string
+	DBName() string
+	DBUser() string
+	DBPassword() string
+	DBMaxOpenConns() int
+	DBMaxIdleConns() int
+	DBMaxConnLifetime() int
+	DBMaxIdleConnLifetime() int
+}
+
+func Init(env Env) (*sql.DB, error) {
+	dataSource := "user=" + env.DBUser() +
+		" password=" + env.DBPassword() +
+		" dbname=" + env.DBName() +
+		" host=" + env.DBHost() +
+		" port=" + env.DBPort() +
 		" sslmode=disable"
 
 	db, err := sql.Open("postgres", dataSource)
@@ -20,20 +31,20 @@ func Init(env interfaces.Env) (*sql.DB, error) {
 		return nil, err
 	}
 
-	if env.GetDBMaxOpenConns() > 0 {
-		db.SetMaxOpenConns(env.GetDBMaxOpenConns())
+	if env.DBMaxOpenConns() > 0 {
+		db.SetMaxOpenConns(env.DBMaxOpenConns())
 	}
 
-	if env.GetDBMaxIdleConns() > 0 {
-		db.SetMaxIdleConns(env.GetDBMaxIdleConns())
+	if env.DBMaxIdleConns() > 0 {
+		db.SetMaxIdleConns(env.DBMaxIdleConns())
 	}
 
-	if env.GetDBMaxConnLifetime() > 0 {
-		db.SetConnMaxLifetime(time.Second * time.Duration(env.GetDBMaxConnLifetime()))
+	if env.DBMaxConnLifetime() > 0 {
+		db.SetConnMaxLifetime(time.Second * time.Duration(env.DBMaxConnLifetime()))
 	}
 
-	if env.GetDBMaxIdleConnLifetime() > 0 {
-		db.SetConnMaxIdleTime(time.Second * time.Duration(env.GetDBMaxIdleConnLifetime()))
+	if env.DBMaxIdleConnLifetime() > 0 {
+		db.SetConnMaxIdleTime(time.Second * time.Duration(env.DBMaxIdleConnLifetime()))
 	}
 
 	if err = db.Ping(); err != nil {

+ 132 - 89
internal/services/env/env.go

@@ -3,49 +3,39 @@ package env
 import (
 	"flag"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
 	"github.com/spf13/viper"
 )
 
 const defaultConfigPath = "../../.env"
 
-type env struct {
-	AppPort string `mapstructure:"APP_PORT"`
-
-	DBHost     string `mapstructure:"DB_HOST"`
-	DBPort     string `mapstructure:"DB_PORT"`
-	DBName     string `mapstructure:"DB_NAME"`
-	DBUser     string `mapstructure:"DB_USER"`
-	DBPassword string `mapstructure:"DB_PASSWORD"`
-
-	DBMaxOpenConns        int `mapstructure:"DB_MAX_OPEN_CONNS"`
-	DBMaxIdleConns        int `mapstructure:"DB_MAX_IDLE_CONNS"`
-	DBMaxConnLifetime     int `mapstructure:"DB_MAX_CONN_LIFETIME"`
-	DBMaxIdleConnLifetime int `mapstructure:"DB_MAX_IDLE_CONN_LIFETIME"`
-
-	CORSAllowOrigins string `mapstructure:"CORS_ALLOW_ORIGING"`
-	CORSAllowMethods string `mapstructure:"CORS_ALLOW_METHODS"`
-
-	JWTSecretKey string `mapstructure:"JWT_SECRET_KEY"`
-	JWTLifeTime  int    `mapstructure:"JWT_LIFETIME"`
-	JWTCookie    string `mapstructure:"JWT_COOKIE"`
-
-	BasicAuthUser     string `mapstructure:"BASIC_AUTH_USER"`
-	BasicAuthPassword string `mapstructure:"BASIC_AUTH_PASSWORD"`
-
-	SMTPHost     string `mapstructure:"SMTP_HOST"`
-	SMTPPort     string `mapstructure:"SMTP_PORT"`
-	SMTPUser     string `mapstructure:"SMTP_USER"`
-	SMTPPassword string `mapstructure:"SMTP_PASSWORD"`
-
-	ErrorsEmail string `mapstructure:"ERRORS_EMAIL"`
-
-	GAKey string `mapstructure:"GA_KEY"`
-
-	StaticVersion int `mapstructure:"STATIC_VERSION"`
-}
-
-func Init() (interfaces.Env, error) {
+type Service struct {
+	appPort               string
+	dbHost                string
+	dbPort                string
+	dbName                string
+	dbUser                string
+	dbPassword            string
+	dbMaxOpenConns        int
+	dbMaxIdleConns        int
+	dbMaxConnLifetime     int
+	dbMaxIdleConnLifetime int
+	corsAllowOrigins      string
+	corsAllowMethods      string
+	jwtSecretKey          string
+	jwtLifeTime           int
+	jwtCookie             string
+	basicAuthUser         string
+	basicAuthPassword     string
+	smtpHost              string
+	smtpPort              string
+	smtpUser              string
+	smtpPassword          string
+	errorsEmail           string
+	gaKey                 string
+	staticVersion         int
+}
+
+func Init() (*Service, error) {
 	var configPath string
 	flag.StringVar(&configPath, "config", "", "Path to .env config file")
 	flag.Parse()
@@ -62,104 +52,157 @@ func Init() (interfaces.Env, error) {
 		return nil, err
 	}
 
-	res := &env{}
-	err := viper.Unmarshal(&res)
+	s := struct {
+		AppPort               string `mapstructure:"APP_PORT"`
+		DBHost                string `mapstructure:"DB_HOST"`
+		DBPort                string `mapstructure:"DB_PORT"`
+		DBName                string `mapstructure:"DB_NAME"`
+		DBUser                string `mapstructure:"DB_USER"`
+		DBPassword            string `mapstructure:"DB_PASSWORD"`
+		DBMaxOpenConns        int    `mapstructure:"DB_MAX_OPEN_CONNS"`
+		DBMaxIdleConns        int    `mapstructure:"DB_MAX_IDLE_CONNS"`
+		DBMaxConnLifetime     int    `mapstructure:"DB_MAX_CONN_LIFETIME"`
+		DBMaxIdleConnLifetime int    `mapstructure:"DB_MAX_IDLE_CONN_LIFETIME"`
+		CORSAllowOrigins      string `mapstructure:"CORS_ALLOW_ORIGING"`
+		CORSAllowMethods      string `mapstructure:"CORS_ALLOW_METHODS"`
+		JWTSecretKey          string `mapstructure:"JWT_SECRET_KEY"`
+		JWTLifeTime           int    `mapstructure:"JWT_LIFETIME"`
+		JWTCookie             string `mapstructure:"JWT_COOKIE"`
+		BasicAuthUser         string `mapstructure:"BASIC_AUTH_USER"`
+		BasicAuthPassword     string `mapstructure:"BASIC_AUTH_PASSWORD"`
+		SMTPHost              string `mapstructure:"SMTP_HOST"`
+		SMTPPort              string `mapstructure:"SMTP_PORT"`
+		SMTPUser              string `mapstructure:"SMTP_USER"`
+		SMTPPassword          string `mapstructure:"SMTP_PASSWORD"`
+		ErrorsEmail           string `mapstructure:"ERRORS_EMAIL"`
+		GAKey                 string `mapstructure:"GA_KEY"`
+		StaticVersion         int    `mapstructure:"STATIC_VERSION"`
+	}{}
+
+	if err := viper.Unmarshal(&s); err != nil {
+		return nil, err
+	}
 
-	return res, err
+	return &Service{
+		appPort:               s.AppPort,
+		dbHost:                s.DBHost,
+		dbPort:                s.DBPort,
+		dbName:                s.DBName,
+		dbUser:                s.DBUser,
+		dbPassword:            s.DBPassword,
+		dbMaxOpenConns:        s.DBMaxOpenConns,
+		dbMaxIdleConns:        s.DBMaxIdleConns,
+		dbMaxConnLifetime:     s.DBMaxConnLifetime,
+		dbMaxIdleConnLifetime: s.DBMaxIdleConnLifetime,
+		corsAllowOrigins:      s.CORSAllowOrigins,
+		corsAllowMethods:      s.CORSAllowMethods,
+		jwtSecretKey:          s.JWTSecretKey,
+		jwtLifeTime:           s.JWTLifeTime,
+		jwtCookie:             s.JWTCookie,
+		basicAuthUser:         s.BasicAuthUser,
+		basicAuthPassword:     s.BasicAuthPassword,
+		smtpHost:              s.SMTPHost,
+		smtpPort:              s.SMTPPort,
+		smtpUser:              s.SMTPUser,
+		smtpPassword:          s.SMTPPassword,
+		errorsEmail:           s.ErrorsEmail,
+		gaKey:                 s.GAKey,
+		staticVersion:         s.StaticVersion,
+	}, nil
 }
 
-func (e *env) GetAppPort() string {
-	return e.AppPort
+func (e *Service) AppPort() string {
+	return e.appPort
 }
 
-func (e *env) GetDBHost() string {
-	return e.DBHost
+func (e *Service) DBHost() string {
+	return e.dbHost
 }
 
-func (e *env) GetDBPort() string {
-	return e.DBPort
+func (e *Service) DBPort() string {
+	return e.dbPort
 }
 
-func (e *env) GetDBName() string {
-	return e.DBName
+func (e *Service) DBName() string {
+	return e.dbName
 }
 
-func (e *env) GetDBUser() string {
-	return e.DBUser
+func (e *Service) DBUser() string {
+	return e.dbUser
 }
 
-func (e *env) GetDBPassword() string {
-	return e.DBPassword
+func (e *Service) DBPassword() string {
+	return e.dbPassword
 }
 
-func (e *env) GetCORSAllowOrigins() string {
-	return e.CORSAllowOrigins
+func (e *Service) CORSAllowOrigins() string {
+	return e.corsAllowOrigins
 }
 
-func (e *env) GetCORSAllowMethods() string {
-	return e.CORSAllowMethods
+func (e *Service) CORSAllowMethods() string {
+	return e.corsAllowMethods
 }
 
-func (e *env) GetDBMaxOpenConns() int {
-	return e.DBMaxOpenConns
+func (e *Service) DBMaxOpenConns() int {
+	return e.dbMaxOpenConns
 }
 
-func (e *env) GetDBMaxIdleConns() int {
-	return e.DBMaxIdleConns
+func (e *Service) DBMaxIdleConns() int {
+	return e.dbMaxIdleConns
 }
 
-func (e *env) GetDBMaxConnLifetime() int {
-	return e.DBMaxConnLifetime
+func (e *Service) DBMaxConnLifetime() int {
+	return e.dbMaxConnLifetime
 }
 
-func (e *env) GetDBMaxIdleConnLifetime() int {
-	return e.DBMaxIdleConnLifetime
+func (e *Service) DBMaxIdleConnLifetime() int {
+	return e.dbMaxIdleConnLifetime
 }
 
-func (e *env) GetSMTPHost() string {
-	return e.SMTPHost
+func (e *Service) SMTPHost() string {
+	return e.smtpHost
 }
 
-func (e *env) GetSMTPPort() string {
-	return e.SMTPPort
+func (e *Service) SMTPPort() string {
+	return e.smtpPort
 }
 
-func (e *env) GetSMTPUser() string {
-	return e.SMTPUser
+func (e *Service) SMTPUser() string {
+	return e.smtpUser
 }
 
-func (e *env) GetSMTPPassword() string {
-	return e.SMTPPassword
+func (e *Service) SMTPPassword() string {
+	return e.smtpPassword
 }
 
-func (e *env) GetJWTSecretKey() string {
-	return e.JWTSecretKey
+func (e *Service) JWTSecretKey() string {
+	return e.jwtSecretKey
 }
 
-func (e *env) GetJWTCookie() string {
-	return e.JWTCookie
+func (e *Service) JWTCookie() string {
+	return e.jwtCookie
 }
 
-func (e *env) GetJWTLifetime() int {
-	return e.JWTLifeTime
+func (e *Service) JWTLifetime() int {
+	return e.jwtLifeTime
 }
 
-func (e *env) GetErrorsEmail() string {
-	return e.ErrorsEmail
+func (e *Service) ErrorsEmail() string {
+	return e.errorsEmail
 }
 
-func (e *env) GetBasicAuthUser() string {
-	return e.BasicAuthUser
+func (e *Service) BasicAuthUser() string {
+	return e.basicAuthUser
 }
 
-func (e *env) GetBasicAuthPassword() string {
-	return e.BasicAuthPassword
+func (e *Service) BasicAuthPassword() string {
+	return e.basicAuthPassword
 }
 
-func (e *env) GetStaticVersion() int {
-	return e.StaticVersion
+func (e *Service) StaticVersion() int {
+	return e.staticVersion
 }
 
-func (e *env) GetGAKey() string {
-	return e.GAKey
+func (e *Service) GAKey() string {
+	return e.gaKey
 }

+ 97 - 31
internal/services/handler/admin/article.go

@@ -1,33 +1,90 @@
 package admin
 
 import (
+	"context"
 	"strconv"
 
+	"github.com/go-playground/validator/v10"
+	"github.com/gofiber/fiber/v2"
+	"github.com/golang-jwt/jwt/v4"
+
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/mapper"
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	"github.com/go-playground/validator/v10"
-	"github.com/gofiber/fiber/v2"
+)
+
+type (
+	CacheService interface {
+		FlushAll()
+	}
+
+	ArticleRepository interface {
+		GetAll(ctx context.Context) ([]models.Article, error)
+		GetByURL(ctx context.Context, url string) (*models.Article, error)
+		GetByID(ctx context.Context, ID int) (*models.Article, error)
+		Add(ctx context.Context, m models.Article) (int, error)
+		Update(ctx context.Context, m models.Article) error
+		Delete(ctx context.Context, ID int) error
+	}
+
+	TagRepository interface {
+		GetAll(ctx context.Context) ([]models.Tag, error)
+		IsUsed(ctx context.Context, ID int) (bool, error)
+		GetByArticleID(ctx context.Context, ID int) ([]models.Tag, error)
+		GetByURL(ctx context.Context, tag string) (*models.Tag, error)
+		GetByID(ctx context.Context, ID int) (*models.Tag, error)
+		Add(ctx context.Context, m models.Tag) error
+		Update(ctx context.Context, m models.Tag) error
+		Delete(ctx context.Context, ID int) error
+	}
+
+	ArticleTagRepository interface {
+		Add(ctx context.Context, articleID int, tagIDs []int) error
+		Delete(ctx context.Context, articleID int, tagIDs []int) error
+		DeleteByArticleID(ctx context.Context, articleID int) error
+	}
+
+	AuthService interface {
+		GeneratePasswordHash(password string) (string, error)
+		IsCorrectPassword(password string, hash string) bool
+		GenerateToken(user models.User) (string, error)
+		GetClaims(fctx *fiber.Ctx) jwt.MapClaims
+	}
+
+	EnvService interface {
+		JWTCookie() string
+		JWTLifetime() int
+	}
+
+	UserRepository interface {
+		Get(ctx context.Context, username string) (*models.User, error)
+		Add(ctx context.Context, username string, password string) (int, error)
+		UpdatePassword(ctx context.Context, id int, newPassword string) error
+	}
 )
 
 const errArticleExists = "Статья с данным URL уже существует"
 
-func ArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func ArticleHandler(articleRepository ArticleRepository) fiber.Handler {
 	return func(ctx *fiber.Ctx) error {
-		articles, err := sp.GetArticleRepository().GetAll(ctx.Context())
+		articles, err := articleRepository.GetAll(ctx.Context())
 		if err != nil {
 			return err
 		}
 
 		return ctx.Render("admin/article", fiber.Map{
-			"articles": mapper.ConvertArticleModelsToDTO(articles),
+			"articles": mapper.ToArticleDTOList(articles),
 			"section":  "article",
 		}, "admin/_layout")
 	}
 }
 
-func AddArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func AddArticleHandler(
+	articleRepository ArticleRepository,
+	tagRepository TagRepository,
+	articleTagRepository ArticleTagRepository,
+	cacheService CacheService,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		var validate = validator.New()
@@ -42,12 +99,12 @@ func AddArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			ActiveTags: make(map[int]bool),
 		}
 
-		tags, err := sp.GetTagRepository().GetAll(ctx)
+		tags, err := tagRepository.GetAll(ctx)
 		if err != nil {
 			return err
 		}
 
-		tagsDTO := mapper.ConvertTagModelsToDTO(tags)
+		tagsDTO := mapper.ToTagDTOList(tags)
 
 		if fctx.Method() == fiber.MethodPost {
 			if err = fctx.BodyParser(&form); err != nil {
@@ -58,7 +115,7 @@ func AddArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				validateErrors = helpers.FormatValidateErrors(err, trans)
 			}
 
-			if res, _ := sp.GetArticleRepository().GetByURL(ctx, form.URL); res != nil {
+			if res, _ := articleRepository.GetByURL(ctx, form.URL); res != nil {
 				validateErrors["ArticleForm.URL"] = errArticleExists
 			}
 
@@ -77,23 +134,23 @@ func AddArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			}
 
 			if len(validateErrors) == 0 {
-				articleModel, err := mapper.ConvertArticleFormToModel(form)
+				articleModel, err := mapper.ToArticle(form)
 				if err != nil {
 					return err
 				}
 
-				articleID, articleErr := sp.GetArticleRepository().Add(ctx, *articleModel)
+				articleID, articleErr := articleRepository.Add(ctx, *articleModel)
 				if articleErr != nil {
 					return articleErr
 				}
 
 				if len(form.Tags) > 0 {
-					if err = sp.GetArticleTagRepository().Add(ctx, articleID, tagIDs); err != nil {
+					if err = articleTagRepository.Add(ctx, articleID, tagIDs); err != nil {
 						return err
 					}
 				}
 
-				sp.GetCacheService().FlushAll()
+				cacheService.FlushAll()
 
 				return fctx.Redirect("/admin")
 			}
@@ -110,7 +167,12 @@ func AddArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 	}
 }
 
-func EditArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func EditArticleHandler(
+	articleRepository ArticleRepository,
+	tagRepository TagRepository,
+	articleTagRepository ArticleTagRepository,
+	cacheService CacheService,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		var validate = validator.New()
@@ -126,7 +188,7 @@ func EditArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			return err
 		}
 
-		article, err := sp.GetArticleRepository().GetByID(ctx, ID)
+		article, err := articleRepository.GetByID(ctx, ID)
 		if err != nil {
 			return err
 		}
@@ -134,21 +196,21 @@ func EditArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			return fiber.ErrNotFound
 		}
 
-		articleTags, err := sp.GetTagRepository().GetByArticleID(ctx, ID)
+		articleTags, err := tagRepository.GetByArticleID(ctx, ID)
 		if err != nil {
 			return err
 		}
 
-		tags, err := sp.GetTagRepository().GetAll(ctx)
+		tags, err := tagRepository.GetAll(ctx)
 		if err != nil {
 			return err
 		}
 
-		tagsDTO := mapper.ConvertTagModelsToDTO(tags)
+		tagsDTO := mapper.ToTagDTOList(tags)
 
 		var form *models.ArticleForm
 		if fctx.Method() == fiber.MethodGet {
-			form = mapper.ConvertArticleModelToForm(*article, articleTags)
+			form = mapper.ToArticleForm(*article, articleTags)
 		} else if fctx.Method() == fiber.MethodPost {
 			form = &models.ArticleForm{
 				ID:         ID,
@@ -163,7 +225,7 @@ func EditArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				validateErrors = helpers.FormatValidateErrors(err, trans)
 			}
 
-			if res, _ := sp.GetArticleRepository().GetByURL(ctx, form.URL); res != nil {
+			if res, _ := articleRepository.GetByURL(ctx, form.URL); res != nil {
 				if res.ID != ID {
 					validateErrors["ArticleForm.URL"] = errArticleExists
 				}
@@ -184,12 +246,12 @@ func EditArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			}
 
 			if len(validateErrors) == 0 {
-				articleModel, err := mapper.ConvertArticleFormToModel(*form)
+				articleModel, err := mapper.ToArticle(*form)
 				if err != nil {
 					return err
 				}
 
-				err = sp.GetArticleRepository().Update(ctx, *articleModel)
+				err = articleRepository.Update(ctx, *articleModel)
 				if err != nil {
 					return err
 				}
@@ -211,18 +273,18 @@ func EditArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				}
 
 				if len(tagsToAdd) > 0 {
-					if err = sp.GetArticleTagRepository().Add(ctx, ID, tagsToAdd); err != nil {
+					if err = articleTagRepository.Add(ctx, ID, tagsToAdd); err != nil {
 						return err
 					}
 				}
 
 				if len(tagsToDelete) > 0 {
-					if err = sp.GetArticleTagRepository().Delete(ctx, ID, tagsToDelete); err != nil {
+					if err = articleTagRepository.Delete(ctx, ID, tagsToDelete); err != nil {
 						return err
 					}
 				}
 
-				sp.GetCacheService().FlushAll()
+				cacheService.FlushAll()
 
 				if fctx.FormValue("action", "save") == "save" {
 					return fctx.Redirect("/admin")
@@ -241,7 +303,11 @@ func EditArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 	}
 }
 
-func DeleteArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func DeleteArticleHandler(
+	articleRepository ArticleRepository,
+	articleTagRepository ArticleTagRepository,
+	cacheService CacheService,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		ID, err := strconv.Atoi(fctx.Params("id"))
@@ -249,23 +315,23 @@ func DeleteArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			return err
 		}
 
-		article, err := sp.GetArticleRepository().GetByID(ctx, ID)
+		article, err := articleRepository.GetByID(ctx, ID)
 		if err != nil {
 			return err
 		}
 
 		if fctx.Method() == fiber.MethodPost {
-			err = sp.GetArticleTagRepository().DeleteByArticleID(ctx, ID)
+			err = articleTagRepository.DeleteByArticleID(ctx, ID)
 			if err != nil {
 				return err
 			}
 
-			err = sp.GetArticleRepository().Delete(ctx, ID)
+			err = articleRepository.Delete(ctx, ID)
 			if err != nil {
 				return err
 			}
 
-			sp.GetCacheService().FlushAll()
+			cacheService.FlushAll()
 
 			return fctx.Redirect("/admin")
 		}

+ 18 - 11
internal/services/handler/admin/auth.go

@@ -2,15 +2,20 @@ package admin
 
 import (
 	"database/sql"
+	"errors"
 	"time"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 )
 
-func LoginHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func LoginHandler(
+	envService EnvService,
+	authService AuthService,
+	userRepository UserRepository,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		var validate = validator.New()
@@ -28,25 +33,25 @@ func LoginHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			}
 
 			if !hasErrors {
-				user, err := sp.GetUserRepository().Get(ctx, form.Username)
+				user, err := userRepository.Get(ctx, form.Username)
 				if err != nil {
-					if err != sql.ErrNoRows {
+					if !errors.Is(err, sql.ErrNoRows) {
 						return err
 					}
 					hasErrors = true
 				}
 
 				if !hasErrors {
-					if sp.GetAuthService().IsCorrectPassword(form.Password, user.Password) {
-						token, err := sp.GetAuthService().GenerateToken(*user)
+					if authService.IsCorrectPassword(form.Password, user.Password) {
+						token, err := authService.GenerateToken(*user)
 						if err != nil {
 							return err
 						}
 
 						cookie := new(fiber.Cookie)
-						cookie.Name = sp.GetEnvService().GetJWTCookie()
+						cookie.Name = envService.JWTCookie()
 						cookie.Value = token
-						cookie.Expires = time.Now().Add(time.Duration(sp.GetEnvService().GetJWTLifetime()) * time.Second)
+						cookie.Expires = time.Now().Add(time.Duration(envService.JWTLifetime()) * time.Second)
 						fctx.Cookie(cookie)
 
 						return fctx.Redirect("/admin")
@@ -63,10 +68,12 @@ func LoginHandler(sp interfaces.ServiceProvider) fiber.Handler {
 	}
 }
 
-func LogoutHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func LogoutHandler(
+	envService EnvService,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		cookie := new(fiber.Cookie)
-		cookie.Name = sp.GetEnvService().GetJWTCookie()
+		cookie.Name = envService.JWTCookie()
 		cookie.Expires = time.Now().Add(-1 * time.Second)
 		fctx.Cookie(cookie)
 

+ 31 - 20
internal/services/handler/admin/tag.go

@@ -3,31 +3,36 @@ package admin
 import (
 	"strconv"
 
+	"github.com/go-playground/validator/v10"
+	"github.com/gofiber/fiber/v2"
+
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/mapper"
 	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	"github.com/go-playground/validator/v10"
-	"github.com/gofiber/fiber/v2"
 )
 
 const errTagExists = "Тег с данным URL уже существует"
 
-func TagHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func TagHandler(
+	tagRepository TagRepository,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
-		tags, err := sp.GetTagRepository().GetAll(fctx.Context())
+		tags, err := tagRepository.GetAll(fctx.Context())
 		if err != nil {
 			return err
 		}
 
 		return fctx.Render("admin/tag", fiber.Map{
-			"tags":    mapper.ConvertTagModelsToDTO(tags),
+			"tags":    mapper.ToTagDTOList(tags),
 			"section": "tag",
 		}, "admin/_layout")
 	}
 }
 
-func AddTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func AddTagHandler(
+	tagRepository TagRepository,
+	cacheService CacheService,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		var form models.TagForm
@@ -48,17 +53,17 @@ func AddTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				validateErrors = helpers.FormatValidateErrors(err, trans)
 			}
 
-			if res, _ := sp.GetTagRepository().GetByURL(ctx, form.URL); res != nil {
+			if res, _ := tagRepository.GetByURL(ctx, form.URL); res != nil {
 				validateErrors["TagForm.URL"] = errTagExists
 			}
 
 			if len(validateErrors) == 0 {
-				err = sp.GetTagRepository().Add(ctx, mapper.ConvertTagFormToModel(form))
+				err = tagRepository.Add(ctx, mapper.ToTag(form))
 				if err != nil {
 					return err
 				}
 
-				sp.GetCacheService().FlushAll()
+				cacheService.FlushAll()
 
 				return fctx.Redirect("/admin/tag")
 			}
@@ -73,7 +78,10 @@ func AddTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
 	}
 }
 
-func EditTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func EditTagHandler(
+	tagRepository TagRepository,
+	cacheService CacheService,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		var validate = validator.New()
@@ -89,7 +97,7 @@ func EditTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			return err
 		}
 
-		tag, err := sp.GetTagRepository().GetByID(ctx, ID)
+		tag, err := tagRepository.GetByID(ctx, ID)
 		if err != nil {
 			return err
 		}
@@ -109,19 +117,19 @@ func EditTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				validateErrors = helpers.FormatValidateErrors(err, trans)
 			}
 
-			if res, _ := sp.GetTagRepository().GetByURL(ctx, form.URL); res != nil {
+			if res, _ := tagRepository.GetByURL(ctx, form.URL); res != nil {
 				if res.ID != ID {
 					validateErrors["TagForm.URL"] = errTagExists
 				}
 			}
 
 			if len(validateErrors) == 0 {
-				err = sp.GetTagRepository().Update(ctx, mapper.ConvertTagFormToModel(form))
+				err = tagRepository.Update(ctx, mapper.ToTag(form))
 				if err != nil {
 					return err
 				}
 
-				sp.GetCacheService().FlushAll()
+				cacheService.FlushAll()
 
 				return fctx.Redirect("/admin/tag")
 			}
@@ -136,7 +144,10 @@ func EditTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
 	}
 }
 
-func DeleteTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func DeleteTagHandler(
+	tagRepository TagRepository,
+	cacheService CacheService,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		ID, err := strconv.Atoi(fctx.Params("id"))
@@ -144,23 +155,23 @@ func DeleteTagHandler(sp interfaces.ServiceProvider) fiber.Handler {
 			return err
 		}
 
-		tag, err := sp.GetTagRepository().GetByID(ctx, ID)
+		tag, err := tagRepository.GetByID(ctx, ID)
 		if err != nil {
 			return err
 		}
 
-		used, err := sp.GetTagRepository().IsUsed(ctx, ID)
+		used, err := tagRepository.IsUsed(ctx, ID)
 		if err != nil {
 			return err
 		}
 
 		if fctx.Method() == fiber.MethodPost {
-			err = sp.GetTagRepository().Delete(ctx, ID)
+			err = tagRepository.Delete(ctx, ID)
 			if err != nil {
 				return err
 			}
 
-			sp.GetCacheService().FlushAll()
+			cacheService.FlushAll()
 
 			return fctx.Redirect("/admin/tag")
 		}

+ 13 - 9
internal/services/handler/admin/user.go

@@ -1,17 +1,21 @@
 package admin
 
 import (
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
 	"github.com/go-playground/validator/v10"
 	"github.com/gofiber/fiber/v2"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/auth"
 )
 
 // nolint
 const errIncorrectOldPassword = "Неверный старый пароль"
 
-func ChangePassword(sp interfaces.ServiceProvider) fiber.Handler {
+func ChangePassword(
+	authService AuthService,
+	userRepository UserRepository,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		var validate = validator.New()
@@ -34,20 +38,20 @@ func ChangePassword(sp interfaces.ServiceProvider) fiber.Handler {
 			}
 
 			if len(validateErrors) == 0 {
-				claims := sp.GetAuthService().GetClaims(fctx)
+				claims := authService.GetClaims(fctx)
 
-				user, err := sp.GetUserRepository().Get(ctx, claims["name"].(string))
+				user, err := userRepository.Get(ctx, claims[auth.ClaimNameKey].(string))
 				if err != nil {
 					return err
 				}
 
-				if sp.GetAuthService().IsCorrectPassword(form.OldPassword, user.Password) {
-					newPassword, err := sp.GetAuthService().GeneratePasswordHash(form.NewPassword)
+				if authService.IsCorrectPassword(form.OldPassword, user.Password) {
+					newPassword, err := authService.GeneratePasswordHash(form.NewPassword)
 					if err != nil {
 						return err
 					}
 
-					if err = sp.GetUserRepository().UpdatePassword(ctx, user.ID, newPassword); err != nil {
+					if err = userRepository.UpdatePassword(ctx, user.ID, newPassword); err != nil {
 						return err
 					}
 

+ 15 - 11
internal/services/handler/article.go

@@ -3,9 +3,9 @@ package handler
 import (
 	"database/sql"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/mapper"
 	"github.com/gofiber/fiber/v2"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/mapper"
 )
 
 const (
@@ -14,15 +14,19 @@ const (
 	articleCacheKey  = "article"
 )
 
-func ArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func ArticleHandler(
+	cacheService CacheService,
+	articleRepository ArticleRepository,
+	tagRepository TagRepository,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		articleReq := fctx.Params(articleParam)
 
-		renderData, found := sp.GetCacheService().Get(articleCacheKey + articleReq)
+		renderData, found := cacheService.Get(articleCacheKey + articleReq)
 
 		if !found {
-			article, err := sp.GetArticleRepository().GetByURL(ctx, articleReq)
+			article, err := articleRepository.GetByURL(ctx, articleReq)
 			if err != nil {
 				if err == sql.ErrNoRows {
 					return fiber.ErrNotFound
@@ -34,18 +38,18 @@ func ArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				return fiber.ErrNotFound
 			}
 
-			articleDTO := mapper.ConvertArticleModelToDTO(*article)
+			articleDTO := mapper.ToArticleDTO(*article)
 
 			// All used tags
-			tags, err := sp.GetTagRepository().GetAllUsed(ctx)
+			tags, err := tagRepository.GetAllUsed(ctx)
 			if err != nil {
 				return err
 			}
 
-			tagsDTO := mapper.ConvertTagModelsToDTO(tags)
+			tagsDTO := mapper.ToTagDTOList(tags)
 
 			// Last articles
-			articles, err := sp.GetArticleRepository().GetAllPreview(ctx)
+			articles, err := articleRepository.GetAllPreview(ctx)
 			if err != nil {
 				return err
 			}
@@ -59,11 +63,11 @@ func ArticleHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				"headKeywords":    articleDTO.MetaKeywords,
 				"pageTitle":       "Статья<br>" + articleDTO.Title,
 				"article":         articleDTO,
-				"sidebarArticles": mapper.ConvertArticlePreviewModelsToDTO(articles),
+				"sidebarArticles": mapper.ToArticlePreviewDTOList(articles),
 				"sidebarTags":     tagsDTO,
 			}
 
-			sp.GetCacheService().Set(articleCacheKey+articleReq, renderData)
+			cacheService.Set(articleCacheKey+articleReq, renderData)
 		}
 
 		return fctx.Render("article", renderData, "_layout")

+ 53 - 52
internal/services/handler/article_test.go

@@ -8,22 +8,18 @@ import (
 	"strconv"
 	"testing"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	repositoryMocks "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/repositories/mocks"
-	sp "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/service_provider"
-	cacheMocks "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/cache/mocks"
 	"github.com/brianvoe/gofakeit/v6"
 	"github.com/gofiber/fiber/v2"
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler/mocks"
 )
 
-func Test_ArticleHandler(t *testing.T) {
-	type cacheMockFunc func(mc *minimock.Controller) interfaces.Cache
-	type tagMockFunc func(mc *minimock.Controller) interfaces.TagRepository
-	type articleMockFunc func(mc *minimock.Controller) interfaces.ArticleRepository
+func TestArticleHandler(t *testing.T) {
+	t.Parallel()
 
 	type req struct {
 		method string
@@ -31,7 +27,6 @@ func Test_ArticleHandler(t *testing.T) {
 	}
 
 	var (
-		mc          = minimock.NewController(t)
 		articleID   = gofakeit.Number(1, 100)
 		publishTime = gofakeit.Date()
 		internalErr = errors.New(gofakeit.Phrase())
@@ -111,9 +106,9 @@ func Test_ArticleHandler(t *testing.T) {
 		req         req
 		res         int
 		err         error
-		cacheMock   cacheMockFunc
-		tagMock     tagMockFunc
-		articleMock articleMockFunc
+		cacheMock   func(mc *minimock.Controller) CacheService
+		tagMock     func(mc *minimock.Controller) TagRepository
+		articleMock func(mc *minimock.Controller) ArticleRepository
 	}{
 		{
 			name: "positive case",
@@ -123,21 +118,21 @@ func Test_ArticleHandler(t *testing.T) {
 			},
 			res: fiber.StatusOK,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 				mock.SetMock.Return()
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 				mock.GetAllUsedMock.Return(tags, nil)
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(articleID), url)
@@ -156,19 +151,19 @@ func Test_ArticleHandler(t *testing.T) {
 			},
 			res: fiber.StatusNotFound,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(articleID), url)
 				}).Return(nil, sql.ErrNoRows)
@@ -184,19 +179,19 @@ func Test_ArticleHandler(t *testing.T) {
 			},
 			res: fiber.StatusInternalServerError,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(articleID), url)
 				}).Return(nil, internalErr)
@@ -212,19 +207,19 @@ func Test_ArticleHandler(t *testing.T) {
 			},
 			res: fiber.StatusNotFound,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(articleID), url)
 				}).Return(&notActiveArticle, nil)
@@ -240,20 +235,20 @@ func Test_ArticleHandler(t *testing.T) {
 			},
 			res: fiber.StatusInternalServerError,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 				mock.GetAllUsedMock.Return(nil, internalErr)
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(articleID), url)
@@ -270,20 +265,20 @@ func Test_ArticleHandler(t *testing.T) {
 			},
 			res: fiber.StatusInternalServerError,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 				mock.GetAllUsedMock.Return(tags, nil)
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(articleID), url)
@@ -298,11 +293,17 @@ func Test_ArticleHandler(t *testing.T) {
 
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
+			t.Parallel()
+
+			mc := minimock.NewController(t)
 			fiberApp := fiber.New(helpers.GetFiberTestConfig())
 			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, nil)
-			serviceProvider := sp.InitMock(tt.cacheMock(mc), tt.tagMock(mc), tt.articleMock(mc))
 
-			fiberApp.Get("/article/:article", ArticleHandler(serviceProvider))
+			fiberApp.Get("/article/:article", ArticleHandler(
+				tt.cacheMock(mc),
+				tt.articleMock(mc),
+				tt.tagMock(mc),
+			))
 
 			fiberRes, fiberErr := fiberApp.Test(fiberReq)
 			assert.Equal(t, tt.res, fiberRes.StatusCode)

+ 35 - 7
internal/services/handler/main_page.go

@@ -1,19 +1,47 @@
 package handler
 
+//go:generate mkdir -p mocks
+//go:generate rm -rf ./mocks/*_minimock.go
+//go:generate minimock -i CacheService,ArticleRepository,TagRepository -o ./mocks/ -s "_minimock.go"
+
 import (
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/mapper"
+	"context"
+
 	"github.com/gofiber/fiber/v2"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/mapper"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
+)
+
+type (
+	CacheService interface {
+		Get(key string) (interface{}, bool)
+		Set(key string, value interface{})
+	}
+
+	ArticleRepository interface {
+		GetByURL(ctx context.Context, url string) (*models.Article, error)
+		GetAllPreview(ctx context.Context) ([]models.ArticlePreview, error)
+		GetPreviewByTagID(ctx context.Context, tagID int) ([]models.ArticlePreview, error)
+	}
+
+	TagRepository interface {
+		GetAllUsed(ctx context.Context) ([]models.Tag, error)
+		GetByURL(ctx context.Context, tag string) (*models.Tag, error)
+	}
 )
 
 const allPreviewArticlesCacheKey = "all-preview-articles"
 
-func MainPageHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func MainPageHandler(
+	cacheService CacheService,
+	articleRepository ArticleRepository,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
-		renderData, found := sp.GetCacheService().Get(allPreviewArticlesCacheKey)
+		renderData, found := cacheService.Get(allPreviewArticlesCacheKey)
 
 		if !found {
-			articles, err := sp.GetArticleRepository().GetAllPreview(fctx.Context())
+			articles, err := articleRepository.GetAllPreview(fctx.Context())
 			if err != nil {
 				return err
 			}
@@ -23,10 +51,10 @@ func MainPageHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				"headDescription": "список статей",
 				"headKeywords":    "Дмитрий Гнатенко, программист, PHP, Go, Golang, программирование, статьи, блог",
 				"pageTitle":       "Список статей",
-				"articles":        mapper.ConvertArticlePreviewModelsToDTO(articles),
+				"articles":        mapper.ToArticlePreviewDTOList(articles),
 			}
 
-			sp.GetCacheService().Set(allPreviewArticlesCacheKey, renderData)
+			cacheService.Set(allPreviewArticlesCacheKey, renderData)
 		}
 
 		return fctx.Render("index", renderData, "_layout")

+ 23 - 22
internal/services/handler/main_page_test.go

@@ -6,21 +6,18 @@ import (
 	"net/http/httptest"
 	"testing"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	repositoryMocks "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/repositories/mocks"
-	sp "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/service_provider"
-	cacheMocks "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/cache/mocks"
 	"github.com/brianvoe/gofakeit/v6"
 	"github.com/gofiber/fiber/v2"
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler/mocks"
 )
 
-func Test_MainPageHandler(t *testing.T) {
-	type cacheMockFunc func(mc *minimock.Controller) interfaces.Cache
-	type articleMockFunc func(mc *minimock.Controller) interfaces.ArticleRepository
+func TestMainPageHandler(t *testing.T) {
+	t.Parallel()
 
 	type req struct {
 		method string
@@ -28,7 +25,6 @@ func Test_MainPageHandler(t *testing.T) {
 	}
 
 	var (
-		mc          = minimock.NewController(t)
 		publishTime = gofakeit.Date()
 		internalErr = errors.New(gofakeit.Phrase())
 
@@ -65,8 +61,8 @@ func Test_MainPageHandler(t *testing.T) {
 		req         req
 		res         int
 		err         error
-		cacheMock   cacheMockFunc
-		articleMock articleMockFunc
+		cacheMock   func(mc *minimock.Controller) CacheService
+		articleMock func(mc *minimock.Controller) ArticleRepository
 	}{
 		{
 			name: "positive case",
@@ -76,15 +72,15 @@ func Test_MainPageHandler(t *testing.T) {
 			},
 			res: fiber.StatusOK,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 				mock.SetMock.Return()
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 				mock.GetAllPreviewMock.Return(previewArticles, nil)
 
 				return mock
@@ -98,14 +94,14 @@ func Test_MainPageHandler(t *testing.T) {
 			},
 			res: fiber.StatusInternalServerError,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 				mock.GetAllPreviewMock.Return(nil, internalErr)
 
 				return mock
@@ -115,11 +111,16 @@ func Test_MainPageHandler(t *testing.T) {
 
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
+			t.Parallel()
+
+			mc := minimock.NewController(t)
 			fiberApp := fiber.New(helpers.GetFiberTestConfig())
 			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, nil)
-			serviceProvider := sp.InitMock(tt.cacheMock(mc), tt.articleMock(mc))
 
-			fiberApp.Get("/", MainPageHandler(serviceProvider))
+			fiberApp.Get("/", MainPageHandler(
+				tt.cacheMock(mc),
+				tt.articleMock(mc),
+			))
 
 			fiberRes, fiberErr := fiberApp.Test(fiberReq)
 			assert.Equal(t, tt.res, fiberRes.StatusCode)

+ 1033 - 0
internal/services/handler/mocks/article_repository_minimock.go

@@ -0,0 +1,1033 @@
+// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+
+package mocks
+
+//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler.ArticleRepository -o article_repository_minimock.go -n ArticleRepositoryMock -p mocks
+
+import (
+	"context"
+	"sync"
+	mm_atomic "sync/atomic"
+	mm_time "time"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
+	"github.com/gojuno/minimock/v3"
+)
+
+// ArticleRepositoryMock implements handler.ArticleRepository
+type ArticleRepositoryMock struct {
+	t          minimock.Tester
+	finishOnce sync.Once
+
+	funcGetAllPreview          func(ctx context.Context) (aa1 []models.ArticlePreview, err error)
+	inspectFuncGetAllPreview   func(ctx context.Context)
+	afterGetAllPreviewCounter  uint64
+	beforeGetAllPreviewCounter uint64
+	GetAllPreviewMock          mArticleRepositoryMockGetAllPreview
+
+	funcGetByURL          func(ctx context.Context, url string) (ap1 *models.Article, err error)
+	inspectFuncGetByURL   func(ctx context.Context, url string)
+	afterGetByURLCounter  uint64
+	beforeGetByURLCounter uint64
+	GetByURLMock          mArticleRepositoryMockGetByURL
+
+	funcGetPreviewByTagID          func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error)
+	inspectFuncGetPreviewByTagID   func(ctx context.Context, tagID int)
+	afterGetPreviewByTagIDCounter  uint64
+	beforeGetPreviewByTagIDCounter uint64
+	GetPreviewByTagIDMock          mArticleRepositoryMockGetPreviewByTagID
+}
+
+// NewArticleRepositoryMock returns a mock for handler.ArticleRepository
+func NewArticleRepositoryMock(t minimock.Tester) *ArticleRepositoryMock {
+	m := &ArticleRepositoryMock{t: t}
+
+	if controller, ok := t.(minimock.MockController); ok {
+		controller.RegisterMocker(m)
+	}
+
+	m.GetAllPreviewMock = mArticleRepositoryMockGetAllPreview{mock: m}
+	m.GetAllPreviewMock.callArgs = []*ArticleRepositoryMockGetAllPreviewParams{}
+
+	m.GetByURLMock = mArticleRepositoryMockGetByURL{mock: m}
+	m.GetByURLMock.callArgs = []*ArticleRepositoryMockGetByURLParams{}
+
+	m.GetPreviewByTagIDMock = mArticleRepositoryMockGetPreviewByTagID{mock: m}
+	m.GetPreviewByTagIDMock.callArgs = []*ArticleRepositoryMockGetPreviewByTagIDParams{}
+
+	t.Cleanup(m.MinimockFinish)
+
+	return m
+}
+
+type mArticleRepositoryMockGetAllPreview struct {
+	optional           bool
+	mock               *ArticleRepositoryMock
+	defaultExpectation *ArticleRepositoryMockGetAllPreviewExpectation
+	expectations       []*ArticleRepositoryMockGetAllPreviewExpectation
+
+	callArgs []*ArticleRepositoryMockGetAllPreviewParams
+	mutex    sync.RWMutex
+
+	expectedInvocations uint64
+}
+
+// ArticleRepositoryMockGetAllPreviewExpectation specifies expectation struct of the ArticleRepository.GetAllPreview
+type ArticleRepositoryMockGetAllPreviewExpectation struct {
+	mock      *ArticleRepositoryMock
+	params    *ArticleRepositoryMockGetAllPreviewParams
+	paramPtrs *ArticleRepositoryMockGetAllPreviewParamPtrs
+	results   *ArticleRepositoryMockGetAllPreviewResults
+	Counter   uint64
+}
+
+// ArticleRepositoryMockGetAllPreviewParams contains parameters of the ArticleRepository.GetAllPreview
+type ArticleRepositoryMockGetAllPreviewParams struct {
+	ctx context.Context
+}
+
+// ArticleRepositoryMockGetAllPreviewParamPtrs contains pointers to parameters of the ArticleRepository.GetAllPreview
+type ArticleRepositoryMockGetAllPreviewParamPtrs struct {
+	ctx *context.Context
+}
+
+// ArticleRepositoryMockGetAllPreviewResults contains results of the ArticleRepository.GetAllPreview
+type ArticleRepositoryMockGetAllPreviewResults struct {
+	aa1 []models.ArticlePreview
+	err error
+}
+
+// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
+// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
+// Optional() makes method check to work in '0 or more' mode.
+// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
+// catch the problems when the expected method call is totally skipped during test run.
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Optional() *mArticleRepositoryMockGetAllPreview {
+	mmGetAllPreview.optional = true
+	return mmGetAllPreview
+}
+
+// Expect sets up expected params for ArticleRepository.GetAllPreview
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Expect(ctx context.Context) *mArticleRepositoryMockGetAllPreview {
+	if mmGetAllPreview.mock.funcGetAllPreview != nil {
+		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
+	}
+
+	if mmGetAllPreview.defaultExpectation == nil {
+		mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{}
+	}
+
+	if mmGetAllPreview.defaultExpectation.paramPtrs != nil {
+		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by ExpectParams functions")
+	}
+
+	mmGetAllPreview.defaultExpectation.params = &ArticleRepositoryMockGetAllPreviewParams{ctx}
+	for _, e := range mmGetAllPreview.expectations {
+		if minimock.Equal(e.params, mmGetAllPreview.defaultExpectation.params) {
+			mmGetAllPreview.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllPreview.defaultExpectation.params)
+		}
+	}
+
+	return mmGetAllPreview
+}
+
+// ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetAllPreview
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) ExpectCtxParam1(ctx context.Context) *mArticleRepositoryMockGetAllPreview {
+	if mmGetAllPreview.mock.funcGetAllPreview != nil {
+		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
+	}
+
+	if mmGetAllPreview.defaultExpectation == nil {
+		mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{}
+	}
+
+	if mmGetAllPreview.defaultExpectation.params != nil {
+		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Expect")
+	}
+
+	if mmGetAllPreview.defaultExpectation.paramPtrs == nil {
+		mmGetAllPreview.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetAllPreviewParamPtrs{}
+	}
+	mmGetAllPreview.defaultExpectation.paramPtrs.ctx = &ctx
+
+	return mmGetAllPreview
+}
+
+// Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetAllPreview
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Inspect(f func(ctx context.Context)) *mArticleRepositoryMockGetAllPreview {
+	if mmGetAllPreview.mock.inspectFuncGetAllPreview != nil {
+		mmGetAllPreview.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetAllPreview")
+	}
+
+	mmGetAllPreview.mock.inspectFuncGetAllPreview = f
+
+	return mmGetAllPreview
+}
+
+// Return sets up results that will be returned by ArticleRepository.GetAllPreview
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
+	if mmGetAllPreview.mock.funcGetAllPreview != nil {
+		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
+	}
+
+	if mmGetAllPreview.defaultExpectation == nil {
+		mmGetAllPreview.defaultExpectation = &ArticleRepositoryMockGetAllPreviewExpectation{mock: mmGetAllPreview.mock}
+	}
+	mmGetAllPreview.defaultExpectation.results = &ArticleRepositoryMockGetAllPreviewResults{aa1, err}
+	return mmGetAllPreview.mock
+}
+
+// Set uses given function f to mock the ArticleRepository.GetAllPreview method
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Set(f func(ctx context.Context) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock {
+	if mmGetAllPreview.defaultExpectation != nil {
+		mmGetAllPreview.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetAllPreview method")
+	}
+
+	if len(mmGetAllPreview.expectations) > 0 {
+		mmGetAllPreview.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetAllPreview method")
+	}
+
+	mmGetAllPreview.mock.funcGetAllPreview = f
+	return mmGetAllPreview.mock
+}
+
+// When sets expectation for the ArticleRepository.GetAllPreview which will trigger the result defined by the following
+// Then helper
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) When(ctx context.Context) *ArticleRepositoryMockGetAllPreviewExpectation {
+	if mmGetAllPreview.mock.funcGetAllPreview != nil {
+		mmGetAllPreview.mock.t.Fatalf("ArticleRepositoryMock.GetAllPreview mock is already set by Set")
+	}
+
+	expectation := &ArticleRepositoryMockGetAllPreviewExpectation{
+		mock:   mmGetAllPreview.mock,
+		params: &ArticleRepositoryMockGetAllPreviewParams{ctx},
+	}
+	mmGetAllPreview.expectations = append(mmGetAllPreview.expectations, expectation)
+	return expectation
+}
+
+// Then sets up ArticleRepository.GetAllPreview return parameters for the expectation previously defined by the When method
+func (e *ArticleRepositoryMockGetAllPreviewExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
+	e.results = &ArticleRepositoryMockGetAllPreviewResults{aa1, err}
+	return e.mock
+}
+
+// Times sets number of times ArticleRepository.GetAllPreview should be invoked
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Times(n uint64) *mArticleRepositoryMockGetAllPreview {
+	if n == 0 {
+		mmGetAllPreview.mock.t.Fatalf("Times of ArticleRepositoryMock.GetAllPreview mock can not be zero")
+	}
+	mm_atomic.StoreUint64(&mmGetAllPreview.expectedInvocations, n)
+	return mmGetAllPreview
+}
+
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) invocationsDone() bool {
+	if len(mmGetAllPreview.expectations) == 0 && mmGetAllPreview.defaultExpectation == nil && mmGetAllPreview.mock.funcGetAllPreview == nil {
+		return true
+	}
+
+	totalInvocations := mm_atomic.LoadUint64(&mmGetAllPreview.mock.afterGetAllPreviewCounter)
+	expectedInvocations := mm_atomic.LoadUint64(&mmGetAllPreview.expectedInvocations)
+
+	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
+}
+
+// GetAllPreview implements handler.ArticleRepository
+func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreview(ctx context.Context) (aa1 []models.ArticlePreview, err error) {
+	mm_atomic.AddUint64(&mmGetAllPreview.beforeGetAllPreviewCounter, 1)
+	defer mm_atomic.AddUint64(&mmGetAllPreview.afterGetAllPreviewCounter, 1)
+
+	if mmGetAllPreview.inspectFuncGetAllPreview != nil {
+		mmGetAllPreview.inspectFuncGetAllPreview(ctx)
+	}
+
+	mm_params := ArticleRepositoryMockGetAllPreviewParams{ctx}
+
+	// Record call args
+	mmGetAllPreview.GetAllPreviewMock.mutex.Lock()
+	mmGetAllPreview.GetAllPreviewMock.callArgs = append(mmGetAllPreview.GetAllPreviewMock.callArgs, &mm_params)
+	mmGetAllPreview.GetAllPreviewMock.mutex.Unlock()
+
+	for _, e := range mmGetAllPreview.GetAllPreviewMock.expectations {
+		if minimock.Equal(*e.params, mm_params) {
+			mm_atomic.AddUint64(&e.Counter, 1)
+			return e.results.aa1, e.results.err
+		}
+	}
+
+	if mmGetAllPreview.GetAllPreviewMock.defaultExpectation != nil {
+		mm_atomic.AddUint64(&mmGetAllPreview.GetAllPreviewMock.defaultExpectation.Counter, 1)
+		mm_want := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.params
+		mm_want_ptrs := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.paramPtrs
+
+		mm_got := ArticleRepositoryMockGetAllPreviewParams{ctx}
+
+		if mm_want_ptrs != nil {
+
+			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
+				mmGetAllPreview.t.Errorf("ArticleRepositoryMock.GetAllPreview got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
+			}
+
+		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
+			mmGetAllPreview.t.Errorf("ArticleRepositoryMock.GetAllPreview got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+		}
+
+		mm_results := mmGetAllPreview.GetAllPreviewMock.defaultExpectation.results
+		if mm_results == nil {
+			mmGetAllPreview.t.Fatal("No results are set for the ArticleRepositoryMock.GetAllPreview")
+		}
+		return (*mm_results).aa1, (*mm_results).err
+	}
+	if mmGetAllPreview.funcGetAllPreview != nil {
+		return mmGetAllPreview.funcGetAllPreview(ctx)
+	}
+	mmGetAllPreview.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetAllPreview. %v", ctx)
+	return
+}
+
+// GetAllPreviewAfterCounter returns a count of finished ArticleRepositoryMock.GetAllPreview invocations
+func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreviewAfterCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetAllPreview.afterGetAllPreviewCounter)
+}
+
+// GetAllPreviewBeforeCounter returns a count of ArticleRepositoryMock.GetAllPreview invocations
+func (mmGetAllPreview *ArticleRepositoryMock) GetAllPreviewBeforeCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetAllPreview.beforeGetAllPreviewCounter)
+}
+
+// Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetAllPreview.
+// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
+func (mmGetAllPreview *mArticleRepositoryMockGetAllPreview) Calls() []*ArticleRepositoryMockGetAllPreviewParams {
+	mmGetAllPreview.mutex.RLock()
+
+	argCopy := make([]*ArticleRepositoryMockGetAllPreviewParams, len(mmGetAllPreview.callArgs))
+	copy(argCopy, mmGetAllPreview.callArgs)
+
+	mmGetAllPreview.mutex.RUnlock()
+
+	return argCopy
+}
+
+// MinimockGetAllPreviewDone returns true if the count of the GetAllPreview invocations corresponds
+// the number of defined expectations
+func (m *ArticleRepositoryMock) MinimockGetAllPreviewDone() bool {
+	if m.GetAllPreviewMock.optional {
+		// Optional methods provide '0 or more' call count restriction.
+		return true
+	}
+
+	for _, e := range m.GetAllPreviewMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			return false
+		}
+	}
+
+	return m.GetAllPreviewMock.invocationsDone()
+}
+
+// MinimockGetAllPreviewInspect logs each unmet expectation
+func (m *ArticleRepositoryMock) MinimockGetAllPreviewInspect() {
+	for _, e := range m.GetAllPreviewMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			m.t.Errorf("Expected call to ArticleRepositoryMock.GetAllPreview with params: %#v", *e.params)
+		}
+	}
+
+	afterGetAllPreviewCounter := mm_atomic.LoadUint64(&m.afterGetAllPreviewCounter)
+	// if default expectation was set then invocations count should be greater than zero
+	if m.GetAllPreviewMock.defaultExpectation != nil && afterGetAllPreviewCounter < 1 {
+		if m.GetAllPreviewMock.defaultExpectation.params == nil {
+			m.t.Error("Expected call to ArticleRepositoryMock.GetAllPreview")
+		} else {
+			m.t.Errorf("Expected call to ArticleRepositoryMock.GetAllPreview with params: %#v", *m.GetAllPreviewMock.defaultExpectation.params)
+		}
+	}
+	// if func was set then invocations count should be greater than zero
+	if m.funcGetAllPreview != nil && afterGetAllPreviewCounter < 1 {
+		m.t.Error("Expected call to ArticleRepositoryMock.GetAllPreview")
+	}
+
+	if !m.GetAllPreviewMock.invocationsDone() && afterGetAllPreviewCounter > 0 {
+		m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetAllPreview but found %d calls",
+			mm_atomic.LoadUint64(&m.GetAllPreviewMock.expectedInvocations), afterGetAllPreviewCounter)
+	}
+}
+
+type mArticleRepositoryMockGetByURL struct {
+	optional           bool
+	mock               *ArticleRepositoryMock
+	defaultExpectation *ArticleRepositoryMockGetByURLExpectation
+	expectations       []*ArticleRepositoryMockGetByURLExpectation
+
+	callArgs []*ArticleRepositoryMockGetByURLParams
+	mutex    sync.RWMutex
+
+	expectedInvocations uint64
+}
+
+// ArticleRepositoryMockGetByURLExpectation specifies expectation struct of the ArticleRepository.GetByURL
+type ArticleRepositoryMockGetByURLExpectation struct {
+	mock      *ArticleRepositoryMock
+	params    *ArticleRepositoryMockGetByURLParams
+	paramPtrs *ArticleRepositoryMockGetByURLParamPtrs
+	results   *ArticleRepositoryMockGetByURLResults
+	Counter   uint64
+}
+
+// ArticleRepositoryMockGetByURLParams contains parameters of the ArticleRepository.GetByURL
+type ArticleRepositoryMockGetByURLParams struct {
+	ctx context.Context
+	url string
+}
+
+// ArticleRepositoryMockGetByURLParamPtrs contains pointers to parameters of the ArticleRepository.GetByURL
+type ArticleRepositoryMockGetByURLParamPtrs struct {
+	ctx *context.Context
+	url *string
+}
+
+// ArticleRepositoryMockGetByURLResults contains results of the ArticleRepository.GetByURL
+type ArticleRepositoryMockGetByURLResults struct {
+	ap1 *models.Article
+	err error
+}
+
+// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
+// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
+// Optional() makes method check to work in '0 or more' mode.
+// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
+// catch the problems when the expected method call is totally skipped during test run.
+func (mmGetByURL *mArticleRepositoryMockGetByURL) Optional() *mArticleRepositoryMockGetByURL {
+	mmGetByURL.optional = true
+	return mmGetByURL
+}
+
+// Expect sets up expected params for ArticleRepository.GetByURL
+func (mmGetByURL *mArticleRepositoryMockGetByURL) Expect(ctx context.Context, url string) *mArticleRepositoryMockGetByURL {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	if mmGetByURL.defaultExpectation == nil {
+		mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
+	}
+
+	if mmGetByURL.defaultExpectation.paramPtrs != nil {
+		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by ExpectParams functions")
+	}
+
+	mmGetByURL.defaultExpectation.params = &ArticleRepositoryMockGetByURLParams{ctx, url}
+	for _, e := range mmGetByURL.expectations {
+		if minimock.Equal(e.params, mmGetByURL.defaultExpectation.params) {
+			mmGetByURL.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByURL.defaultExpectation.params)
+		}
+	}
+
+	return mmGetByURL
+}
+
+// ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetByURL
+func (mmGetByURL *mArticleRepositoryMockGetByURL) ExpectCtxParam1(ctx context.Context) *mArticleRepositoryMockGetByURL {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	if mmGetByURL.defaultExpectation == nil {
+		mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
+	}
+
+	if mmGetByURL.defaultExpectation.params != nil {
+		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Expect")
+	}
+
+	if mmGetByURL.defaultExpectation.paramPtrs == nil {
+		mmGetByURL.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetByURLParamPtrs{}
+	}
+	mmGetByURL.defaultExpectation.paramPtrs.ctx = &ctx
+
+	return mmGetByURL
+}
+
+// ExpectUrlParam2 sets up expected param url for ArticleRepository.GetByURL
+func (mmGetByURL *mArticleRepositoryMockGetByURL) ExpectUrlParam2(url string) *mArticleRepositoryMockGetByURL {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	if mmGetByURL.defaultExpectation == nil {
+		mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{}
+	}
+
+	if mmGetByURL.defaultExpectation.params != nil {
+		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Expect")
+	}
+
+	if mmGetByURL.defaultExpectation.paramPtrs == nil {
+		mmGetByURL.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetByURLParamPtrs{}
+	}
+	mmGetByURL.defaultExpectation.paramPtrs.url = &url
+
+	return mmGetByURL
+}
+
+// Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetByURL
+func (mmGetByURL *mArticleRepositoryMockGetByURL) Inspect(f func(ctx context.Context, url string)) *mArticleRepositoryMockGetByURL {
+	if mmGetByURL.mock.inspectFuncGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetByURL")
+	}
+
+	mmGetByURL.mock.inspectFuncGetByURL = f
+
+	return mmGetByURL
+}
+
+// Return sets up results that will be returned by ArticleRepository.GetByURL
+func (mmGetByURL *mArticleRepositoryMockGetByURL) Return(ap1 *models.Article, err error) *ArticleRepositoryMock {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	if mmGetByURL.defaultExpectation == nil {
+		mmGetByURL.defaultExpectation = &ArticleRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock}
+	}
+	mmGetByURL.defaultExpectation.results = &ArticleRepositoryMockGetByURLResults{ap1, err}
+	return mmGetByURL.mock
+}
+
+// Set uses given function f to mock the ArticleRepository.GetByURL method
+func (mmGetByURL *mArticleRepositoryMockGetByURL) Set(f func(ctx context.Context, url string) (ap1 *models.Article, err error)) *ArticleRepositoryMock {
+	if mmGetByURL.defaultExpectation != nil {
+		mmGetByURL.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetByURL method")
+	}
+
+	if len(mmGetByURL.expectations) > 0 {
+		mmGetByURL.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetByURL method")
+	}
+
+	mmGetByURL.mock.funcGetByURL = f
+	return mmGetByURL.mock
+}
+
+// When sets expectation for the ArticleRepository.GetByURL which will trigger the result defined by the following
+// Then helper
+func (mmGetByURL *mArticleRepositoryMockGetByURL) When(ctx context.Context, url string) *ArticleRepositoryMockGetByURLExpectation {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("ArticleRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	expectation := &ArticleRepositoryMockGetByURLExpectation{
+		mock:   mmGetByURL.mock,
+		params: &ArticleRepositoryMockGetByURLParams{ctx, url},
+	}
+	mmGetByURL.expectations = append(mmGetByURL.expectations, expectation)
+	return expectation
+}
+
+// Then sets up ArticleRepository.GetByURL return parameters for the expectation previously defined by the When method
+func (e *ArticleRepositoryMockGetByURLExpectation) Then(ap1 *models.Article, err error) *ArticleRepositoryMock {
+	e.results = &ArticleRepositoryMockGetByURLResults{ap1, err}
+	return e.mock
+}
+
+// Times sets number of times ArticleRepository.GetByURL should be invoked
+func (mmGetByURL *mArticleRepositoryMockGetByURL) Times(n uint64) *mArticleRepositoryMockGetByURL {
+	if n == 0 {
+		mmGetByURL.mock.t.Fatalf("Times of ArticleRepositoryMock.GetByURL mock can not be zero")
+	}
+	mm_atomic.StoreUint64(&mmGetByURL.expectedInvocations, n)
+	return mmGetByURL
+}
+
+func (mmGetByURL *mArticleRepositoryMockGetByURL) invocationsDone() bool {
+	if len(mmGetByURL.expectations) == 0 && mmGetByURL.defaultExpectation == nil && mmGetByURL.mock.funcGetByURL == nil {
+		return true
+	}
+
+	totalInvocations := mm_atomic.LoadUint64(&mmGetByURL.mock.afterGetByURLCounter)
+	expectedInvocations := mm_atomic.LoadUint64(&mmGetByURL.expectedInvocations)
+
+	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
+}
+
+// GetByURL implements handler.ArticleRepository
+func (mmGetByURL *ArticleRepositoryMock) GetByURL(ctx context.Context, url string) (ap1 *models.Article, err error) {
+	mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1)
+	defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1)
+
+	if mmGetByURL.inspectFuncGetByURL != nil {
+		mmGetByURL.inspectFuncGetByURL(ctx, url)
+	}
+
+	mm_params := ArticleRepositoryMockGetByURLParams{ctx, url}
+
+	// Record call args
+	mmGetByURL.GetByURLMock.mutex.Lock()
+	mmGetByURL.GetByURLMock.callArgs = append(mmGetByURL.GetByURLMock.callArgs, &mm_params)
+	mmGetByURL.GetByURLMock.mutex.Unlock()
+
+	for _, e := range mmGetByURL.GetByURLMock.expectations {
+		if minimock.Equal(*e.params, mm_params) {
+			mm_atomic.AddUint64(&e.Counter, 1)
+			return e.results.ap1, e.results.err
+		}
+	}
+
+	if mmGetByURL.GetByURLMock.defaultExpectation != nil {
+		mm_atomic.AddUint64(&mmGetByURL.GetByURLMock.defaultExpectation.Counter, 1)
+		mm_want := mmGetByURL.GetByURLMock.defaultExpectation.params
+		mm_want_ptrs := mmGetByURL.GetByURLMock.defaultExpectation.paramPtrs
+
+		mm_got := ArticleRepositoryMockGetByURLParams{ctx, url}
+
+		if mm_want_ptrs != nil {
+
+			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
+				mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
+			}
+
+			if mm_want_ptrs.url != nil && !minimock.Equal(*mm_want_ptrs.url, mm_got.url) {
+				mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameter url, want: %#v, got: %#v%s\n", *mm_want_ptrs.url, mm_got.url, minimock.Diff(*mm_want_ptrs.url, mm_got.url))
+			}
+
+		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
+			mmGetByURL.t.Errorf("ArticleRepositoryMock.GetByURL got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+		}
+
+		mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results
+		if mm_results == nil {
+			mmGetByURL.t.Fatal("No results are set for the ArticleRepositoryMock.GetByURL")
+		}
+		return (*mm_results).ap1, (*mm_results).err
+	}
+	if mmGetByURL.funcGetByURL != nil {
+		return mmGetByURL.funcGetByURL(ctx, url)
+	}
+	mmGetByURL.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetByURL. %v %v", ctx, url)
+	return
+}
+
+// GetByURLAfterCounter returns a count of finished ArticleRepositoryMock.GetByURL invocations
+func (mmGetByURL *ArticleRepositoryMock) GetByURLAfterCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter)
+}
+
+// GetByURLBeforeCounter returns a count of ArticleRepositoryMock.GetByURL invocations
+func (mmGetByURL *ArticleRepositoryMock) GetByURLBeforeCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter)
+}
+
+// Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetByURL.
+// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
+func (mmGetByURL *mArticleRepositoryMockGetByURL) Calls() []*ArticleRepositoryMockGetByURLParams {
+	mmGetByURL.mutex.RLock()
+
+	argCopy := make([]*ArticleRepositoryMockGetByURLParams, len(mmGetByURL.callArgs))
+	copy(argCopy, mmGetByURL.callArgs)
+
+	mmGetByURL.mutex.RUnlock()
+
+	return argCopy
+}
+
+// MinimockGetByURLDone returns true if the count of the GetByURL invocations corresponds
+// the number of defined expectations
+func (m *ArticleRepositoryMock) MinimockGetByURLDone() bool {
+	if m.GetByURLMock.optional {
+		// Optional methods provide '0 or more' call count restriction.
+		return true
+	}
+
+	for _, e := range m.GetByURLMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			return false
+		}
+	}
+
+	return m.GetByURLMock.invocationsDone()
+}
+
+// MinimockGetByURLInspect logs each unmet expectation
+func (m *ArticleRepositoryMock) MinimockGetByURLInspect() {
+	for _, e := range m.GetByURLMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			m.t.Errorf("Expected call to ArticleRepositoryMock.GetByURL with params: %#v", *e.params)
+		}
+	}
+
+	afterGetByURLCounter := mm_atomic.LoadUint64(&m.afterGetByURLCounter)
+	// if default expectation was set then invocations count should be greater than zero
+	if m.GetByURLMock.defaultExpectation != nil && afterGetByURLCounter < 1 {
+		if m.GetByURLMock.defaultExpectation.params == nil {
+			m.t.Error("Expected call to ArticleRepositoryMock.GetByURL")
+		} else {
+			m.t.Errorf("Expected call to ArticleRepositoryMock.GetByURL with params: %#v", *m.GetByURLMock.defaultExpectation.params)
+		}
+	}
+	// if func was set then invocations count should be greater than zero
+	if m.funcGetByURL != nil && afterGetByURLCounter < 1 {
+		m.t.Error("Expected call to ArticleRepositoryMock.GetByURL")
+	}
+
+	if !m.GetByURLMock.invocationsDone() && afterGetByURLCounter > 0 {
+		m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetByURL but found %d calls",
+			mm_atomic.LoadUint64(&m.GetByURLMock.expectedInvocations), afterGetByURLCounter)
+	}
+}
+
+type mArticleRepositoryMockGetPreviewByTagID struct {
+	optional           bool
+	mock               *ArticleRepositoryMock
+	defaultExpectation *ArticleRepositoryMockGetPreviewByTagIDExpectation
+	expectations       []*ArticleRepositoryMockGetPreviewByTagIDExpectation
+
+	callArgs []*ArticleRepositoryMockGetPreviewByTagIDParams
+	mutex    sync.RWMutex
+
+	expectedInvocations uint64
+}
+
+// ArticleRepositoryMockGetPreviewByTagIDExpectation specifies expectation struct of the ArticleRepository.GetPreviewByTagID
+type ArticleRepositoryMockGetPreviewByTagIDExpectation struct {
+	mock      *ArticleRepositoryMock
+	params    *ArticleRepositoryMockGetPreviewByTagIDParams
+	paramPtrs *ArticleRepositoryMockGetPreviewByTagIDParamPtrs
+	results   *ArticleRepositoryMockGetPreviewByTagIDResults
+	Counter   uint64
+}
+
+// ArticleRepositoryMockGetPreviewByTagIDParams contains parameters of the ArticleRepository.GetPreviewByTagID
+type ArticleRepositoryMockGetPreviewByTagIDParams struct {
+	ctx   context.Context
+	tagID int
+}
+
+// ArticleRepositoryMockGetPreviewByTagIDParamPtrs contains pointers to parameters of the ArticleRepository.GetPreviewByTagID
+type ArticleRepositoryMockGetPreviewByTagIDParamPtrs struct {
+	ctx   *context.Context
+	tagID *int
+}
+
+// ArticleRepositoryMockGetPreviewByTagIDResults contains results of the ArticleRepository.GetPreviewByTagID
+type ArticleRepositoryMockGetPreviewByTagIDResults struct {
+	aa1 []models.ArticlePreview
+	err error
+}
+
+// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
+// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
+// Optional() makes method check to work in '0 or more' mode.
+// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
+// catch the problems when the expected method call is totally skipped during test run.
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Optional() *mArticleRepositoryMockGetPreviewByTagID {
+	mmGetPreviewByTagID.optional = true
+	return mmGetPreviewByTagID
+}
+
+// Expect sets up expected params for ArticleRepository.GetPreviewByTagID
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Expect(ctx context.Context, tagID int) *mArticleRepositoryMockGetPreviewByTagID {
+	if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation == nil {
+		mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation.paramPtrs != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by ExpectParams functions")
+	}
+
+	mmGetPreviewByTagID.defaultExpectation.params = &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
+	for _, e := range mmGetPreviewByTagID.expectations {
+		if minimock.Equal(e.params, mmGetPreviewByTagID.defaultExpectation.params) {
+			mmGetPreviewByTagID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetPreviewByTagID.defaultExpectation.params)
+		}
+	}
+
+	return mmGetPreviewByTagID
+}
+
+// ExpectCtxParam1 sets up expected param ctx for ArticleRepository.GetPreviewByTagID
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectCtxParam1(ctx context.Context) *mArticleRepositoryMockGetPreviewByTagID {
+	if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation == nil {
+		mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation.params != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect")
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil {
+		mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{}
+	}
+	mmGetPreviewByTagID.defaultExpectation.paramPtrs.ctx = &ctx
+
+	return mmGetPreviewByTagID
+}
+
+// ExpectTagIDParam2 sets up expected param tagID for ArticleRepository.GetPreviewByTagID
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) ExpectTagIDParam2(tagID int) *mArticleRepositoryMockGetPreviewByTagID {
+	if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation == nil {
+		mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{}
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation.params != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Expect")
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation.paramPtrs == nil {
+		mmGetPreviewByTagID.defaultExpectation.paramPtrs = &ArticleRepositoryMockGetPreviewByTagIDParamPtrs{}
+	}
+	mmGetPreviewByTagID.defaultExpectation.paramPtrs.tagID = &tagID
+
+	return mmGetPreviewByTagID
+}
+
+// Inspect accepts an inspector function that has same arguments as the ArticleRepository.GetPreviewByTagID
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Inspect(f func(ctx context.Context, tagID int)) *mArticleRepositoryMockGetPreviewByTagID {
+	if mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("Inspect function is already set for ArticleRepositoryMock.GetPreviewByTagID")
+	}
+
+	mmGetPreviewByTagID.mock.inspectFuncGetPreviewByTagID = f
+
+	return mmGetPreviewByTagID
+}
+
+// Return sets up results that will be returned by ArticleRepository.GetPreviewByTagID
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Return(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
+	if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
+	}
+
+	if mmGetPreviewByTagID.defaultExpectation == nil {
+		mmGetPreviewByTagID.defaultExpectation = &ArticleRepositoryMockGetPreviewByTagIDExpectation{mock: mmGetPreviewByTagID.mock}
+	}
+	mmGetPreviewByTagID.defaultExpectation.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err}
+	return mmGetPreviewByTagID.mock
+}
+
+// Set uses given function f to mock the ArticleRepository.GetPreviewByTagID method
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Set(f func(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error)) *ArticleRepositoryMock {
+	if mmGetPreviewByTagID.defaultExpectation != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("Default expectation is already set for the ArticleRepository.GetPreviewByTagID method")
+	}
+
+	if len(mmGetPreviewByTagID.expectations) > 0 {
+		mmGetPreviewByTagID.mock.t.Fatalf("Some expectations are already set for the ArticleRepository.GetPreviewByTagID method")
+	}
+
+	mmGetPreviewByTagID.mock.funcGetPreviewByTagID = f
+	return mmGetPreviewByTagID.mock
+}
+
+// When sets expectation for the ArticleRepository.GetPreviewByTagID which will trigger the result defined by the following
+// Then helper
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) When(ctx context.Context, tagID int) *ArticleRepositoryMockGetPreviewByTagIDExpectation {
+	if mmGetPreviewByTagID.mock.funcGetPreviewByTagID != nil {
+		mmGetPreviewByTagID.mock.t.Fatalf("ArticleRepositoryMock.GetPreviewByTagID mock is already set by Set")
+	}
+
+	expectation := &ArticleRepositoryMockGetPreviewByTagIDExpectation{
+		mock:   mmGetPreviewByTagID.mock,
+		params: &ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID},
+	}
+	mmGetPreviewByTagID.expectations = append(mmGetPreviewByTagID.expectations, expectation)
+	return expectation
+}
+
+// Then sets up ArticleRepository.GetPreviewByTagID return parameters for the expectation previously defined by the When method
+func (e *ArticleRepositoryMockGetPreviewByTagIDExpectation) Then(aa1 []models.ArticlePreview, err error) *ArticleRepositoryMock {
+	e.results = &ArticleRepositoryMockGetPreviewByTagIDResults{aa1, err}
+	return e.mock
+}
+
+// Times sets number of times ArticleRepository.GetPreviewByTagID should be invoked
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Times(n uint64) *mArticleRepositoryMockGetPreviewByTagID {
+	if n == 0 {
+		mmGetPreviewByTagID.mock.t.Fatalf("Times of ArticleRepositoryMock.GetPreviewByTagID mock can not be zero")
+	}
+	mm_atomic.StoreUint64(&mmGetPreviewByTagID.expectedInvocations, n)
+	return mmGetPreviewByTagID
+}
+
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) invocationsDone() bool {
+	if len(mmGetPreviewByTagID.expectations) == 0 && mmGetPreviewByTagID.defaultExpectation == nil && mmGetPreviewByTagID.mock.funcGetPreviewByTagID == nil {
+		return true
+	}
+
+	totalInvocations := mm_atomic.LoadUint64(&mmGetPreviewByTagID.mock.afterGetPreviewByTagIDCounter)
+	expectedInvocations := mm_atomic.LoadUint64(&mmGetPreviewByTagID.expectedInvocations)
+
+	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
+}
+
+// GetPreviewByTagID implements handler.ArticleRepository
+func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagID(ctx context.Context, tagID int) (aa1 []models.ArticlePreview, err error) {
+	mm_atomic.AddUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter, 1)
+	defer mm_atomic.AddUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter, 1)
+
+	if mmGetPreviewByTagID.inspectFuncGetPreviewByTagID != nil {
+		mmGetPreviewByTagID.inspectFuncGetPreviewByTagID(ctx, tagID)
+	}
+
+	mm_params := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
+
+	// Record call args
+	mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Lock()
+	mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs = append(mmGetPreviewByTagID.GetPreviewByTagIDMock.callArgs, &mm_params)
+	mmGetPreviewByTagID.GetPreviewByTagIDMock.mutex.Unlock()
+
+	for _, e := range mmGetPreviewByTagID.GetPreviewByTagIDMock.expectations {
+		if minimock.Equal(*e.params, mm_params) {
+			mm_atomic.AddUint64(&e.Counter, 1)
+			return e.results.aa1, e.results.err
+		}
+	}
+
+	if mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation != nil {
+		mm_atomic.AddUint64(&mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.Counter, 1)
+		mm_want := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.params
+		mm_want_ptrs := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.paramPtrs
+
+		mm_got := ArticleRepositoryMockGetPreviewByTagIDParams{ctx, tagID}
+
+		if mm_want_ptrs != nil {
+
+			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
+				mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
+			}
+
+			if mm_want_ptrs.tagID != nil && !minimock.Equal(*mm_want_ptrs.tagID, mm_got.tagID) {
+				mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameter tagID, want: %#v, got: %#v%s\n", *mm_want_ptrs.tagID, mm_got.tagID, minimock.Diff(*mm_want_ptrs.tagID, mm_got.tagID))
+			}
+
+		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
+			mmGetPreviewByTagID.t.Errorf("ArticleRepositoryMock.GetPreviewByTagID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+		}
+
+		mm_results := mmGetPreviewByTagID.GetPreviewByTagIDMock.defaultExpectation.results
+		if mm_results == nil {
+			mmGetPreviewByTagID.t.Fatal("No results are set for the ArticleRepositoryMock.GetPreviewByTagID")
+		}
+		return (*mm_results).aa1, (*mm_results).err
+	}
+	if mmGetPreviewByTagID.funcGetPreviewByTagID != nil {
+		return mmGetPreviewByTagID.funcGetPreviewByTagID(ctx, tagID)
+	}
+	mmGetPreviewByTagID.t.Fatalf("Unexpected call to ArticleRepositoryMock.GetPreviewByTagID. %v %v", ctx, tagID)
+	return
+}
+
+// GetPreviewByTagIDAfterCounter returns a count of finished ArticleRepositoryMock.GetPreviewByTagID invocations
+func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDAfterCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetPreviewByTagID.afterGetPreviewByTagIDCounter)
+}
+
+// GetPreviewByTagIDBeforeCounter returns a count of ArticleRepositoryMock.GetPreviewByTagID invocations
+func (mmGetPreviewByTagID *ArticleRepositoryMock) GetPreviewByTagIDBeforeCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetPreviewByTagID.beforeGetPreviewByTagIDCounter)
+}
+
+// Calls returns a list of arguments used in each call to ArticleRepositoryMock.GetPreviewByTagID.
+// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
+func (mmGetPreviewByTagID *mArticleRepositoryMockGetPreviewByTagID) Calls() []*ArticleRepositoryMockGetPreviewByTagIDParams {
+	mmGetPreviewByTagID.mutex.RLock()
+
+	argCopy := make([]*ArticleRepositoryMockGetPreviewByTagIDParams, len(mmGetPreviewByTagID.callArgs))
+	copy(argCopy, mmGetPreviewByTagID.callArgs)
+
+	mmGetPreviewByTagID.mutex.RUnlock()
+
+	return argCopy
+}
+
+// MinimockGetPreviewByTagIDDone returns true if the count of the GetPreviewByTagID invocations corresponds
+// the number of defined expectations
+func (m *ArticleRepositoryMock) MinimockGetPreviewByTagIDDone() bool {
+	if m.GetPreviewByTagIDMock.optional {
+		// Optional methods provide '0 or more' call count restriction.
+		return true
+	}
+
+	for _, e := range m.GetPreviewByTagIDMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			return false
+		}
+	}
+
+	return m.GetPreviewByTagIDMock.invocationsDone()
+}
+
+// MinimockGetPreviewByTagIDInspect logs each unmet expectation
+func (m *ArticleRepositoryMock) MinimockGetPreviewByTagIDInspect() {
+	for _, e := range m.GetPreviewByTagIDMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			m.t.Errorf("Expected call to ArticleRepositoryMock.GetPreviewByTagID with params: %#v", *e.params)
+		}
+	}
+
+	afterGetPreviewByTagIDCounter := mm_atomic.LoadUint64(&m.afterGetPreviewByTagIDCounter)
+	// if default expectation was set then invocations count should be greater than zero
+	if m.GetPreviewByTagIDMock.defaultExpectation != nil && afterGetPreviewByTagIDCounter < 1 {
+		if m.GetPreviewByTagIDMock.defaultExpectation.params == nil {
+			m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID")
+		} else {
+			m.t.Errorf("Expected call to ArticleRepositoryMock.GetPreviewByTagID with params: %#v", *m.GetPreviewByTagIDMock.defaultExpectation.params)
+		}
+	}
+	// if func was set then invocations count should be greater than zero
+	if m.funcGetPreviewByTagID != nil && afterGetPreviewByTagIDCounter < 1 {
+		m.t.Error("Expected call to ArticleRepositoryMock.GetPreviewByTagID")
+	}
+
+	if !m.GetPreviewByTagIDMock.invocationsDone() && afterGetPreviewByTagIDCounter > 0 {
+		m.t.Errorf("Expected %d calls to ArticleRepositoryMock.GetPreviewByTagID but found %d calls",
+			mm_atomic.LoadUint64(&m.GetPreviewByTagIDMock.expectedInvocations), afterGetPreviewByTagIDCounter)
+	}
+}
+
+// MinimockFinish checks that all mocked methods have been called the expected number of times
+func (m *ArticleRepositoryMock) MinimockFinish() {
+	m.finishOnce.Do(func() {
+		if !m.minimockDone() {
+			m.MinimockGetAllPreviewInspect()
+
+			m.MinimockGetByURLInspect()
+
+			m.MinimockGetPreviewByTagIDInspect()
+		}
+	})
+}
+
+// MinimockWait waits for all mocked methods to be called the expected number of times
+func (m *ArticleRepositoryMock) MinimockWait(timeout mm_time.Duration) {
+	timeoutCh := mm_time.After(timeout)
+	for {
+		if m.minimockDone() {
+			return
+		}
+		select {
+		case <-timeoutCh:
+			m.MinimockFinish()
+			return
+		case <-mm_time.After(10 * mm_time.Millisecond):
+		}
+	}
+}
+
+func (m *ArticleRepositoryMock) minimockDone() bool {
+	done := true
+	return done &&
+		m.MinimockGetAllPreviewDone() &&
+		m.MinimockGetByURLDone() &&
+		m.MinimockGetPreviewByTagIDDone()
+}

+ 669 - 0
internal/services/handler/mocks/cache_service_minimock.go

@@ -0,0 +1,669 @@
+// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+
+package mocks
+
+//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler.CacheService -o cache_service_minimock.go -n CacheServiceMock -p mocks
+
+import (
+	"sync"
+	mm_atomic "sync/atomic"
+	mm_time "time"
+
+	"github.com/gojuno/minimock/v3"
+)
+
+// CacheServiceMock implements handler.CacheService
+type CacheServiceMock struct {
+	t          minimock.Tester
+	finishOnce sync.Once
+
+	funcGet          func(key string) (p1 interface{}, b1 bool)
+	inspectFuncGet   func(key string)
+	afterGetCounter  uint64
+	beforeGetCounter uint64
+	GetMock          mCacheServiceMockGet
+
+	funcSet          func(key string, value interface{})
+	inspectFuncSet   func(key string, value interface{})
+	afterSetCounter  uint64
+	beforeSetCounter uint64
+	SetMock          mCacheServiceMockSet
+}
+
+// NewCacheServiceMock returns a mock for handler.CacheService
+func NewCacheServiceMock(t minimock.Tester) *CacheServiceMock {
+	m := &CacheServiceMock{t: t}
+
+	if controller, ok := t.(minimock.MockController); ok {
+		controller.RegisterMocker(m)
+	}
+
+	m.GetMock = mCacheServiceMockGet{mock: m}
+	m.GetMock.callArgs = []*CacheServiceMockGetParams{}
+
+	m.SetMock = mCacheServiceMockSet{mock: m}
+	m.SetMock.callArgs = []*CacheServiceMockSetParams{}
+
+	t.Cleanup(m.MinimockFinish)
+
+	return m
+}
+
+type mCacheServiceMockGet struct {
+	optional           bool
+	mock               *CacheServiceMock
+	defaultExpectation *CacheServiceMockGetExpectation
+	expectations       []*CacheServiceMockGetExpectation
+
+	callArgs []*CacheServiceMockGetParams
+	mutex    sync.RWMutex
+
+	expectedInvocations uint64
+}
+
+// CacheServiceMockGetExpectation specifies expectation struct of the CacheService.Get
+type CacheServiceMockGetExpectation struct {
+	mock      *CacheServiceMock
+	params    *CacheServiceMockGetParams
+	paramPtrs *CacheServiceMockGetParamPtrs
+	results   *CacheServiceMockGetResults
+	Counter   uint64
+}
+
+// CacheServiceMockGetParams contains parameters of the CacheService.Get
+type CacheServiceMockGetParams struct {
+	key string
+}
+
+// CacheServiceMockGetParamPtrs contains pointers to parameters of the CacheService.Get
+type CacheServiceMockGetParamPtrs struct {
+	key *string
+}
+
+// CacheServiceMockGetResults contains results of the CacheService.Get
+type CacheServiceMockGetResults struct {
+	p1 interface{}
+	b1 bool
+}
+
+// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
+// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
+// Optional() makes method check to work in '0 or more' mode.
+// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
+// catch the problems when the expected method call is totally skipped during test run.
+func (mmGet *mCacheServiceMockGet) Optional() *mCacheServiceMockGet {
+	mmGet.optional = true
+	return mmGet
+}
+
+// Expect sets up expected params for CacheService.Get
+func (mmGet *mCacheServiceMockGet) Expect(key string) *mCacheServiceMockGet {
+	if mmGet.mock.funcGet != nil {
+		mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Set")
+	}
+
+	if mmGet.defaultExpectation == nil {
+		mmGet.defaultExpectation = &CacheServiceMockGetExpectation{}
+	}
+
+	if mmGet.defaultExpectation.paramPtrs != nil {
+		mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by ExpectParams functions")
+	}
+
+	mmGet.defaultExpectation.params = &CacheServiceMockGetParams{key}
+	for _, e := range mmGet.expectations {
+		if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
+			mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
+		}
+	}
+
+	return mmGet
+}
+
+// ExpectKeyParam1 sets up expected param key for CacheService.Get
+func (mmGet *mCacheServiceMockGet) ExpectKeyParam1(key string) *mCacheServiceMockGet {
+	if mmGet.mock.funcGet != nil {
+		mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Set")
+	}
+
+	if mmGet.defaultExpectation == nil {
+		mmGet.defaultExpectation = &CacheServiceMockGetExpectation{}
+	}
+
+	if mmGet.defaultExpectation.params != nil {
+		mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Expect")
+	}
+
+	if mmGet.defaultExpectation.paramPtrs == nil {
+		mmGet.defaultExpectation.paramPtrs = &CacheServiceMockGetParamPtrs{}
+	}
+	mmGet.defaultExpectation.paramPtrs.key = &key
+
+	return mmGet
+}
+
+// Inspect accepts an inspector function that has same arguments as the CacheService.Get
+func (mmGet *mCacheServiceMockGet) Inspect(f func(key string)) *mCacheServiceMockGet {
+	if mmGet.mock.inspectFuncGet != nil {
+		mmGet.mock.t.Fatalf("Inspect function is already set for CacheServiceMock.Get")
+	}
+
+	mmGet.mock.inspectFuncGet = f
+
+	return mmGet
+}
+
+// Return sets up results that will be returned by CacheService.Get
+func (mmGet *mCacheServiceMockGet) Return(p1 interface{}, b1 bool) *CacheServiceMock {
+	if mmGet.mock.funcGet != nil {
+		mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Set")
+	}
+
+	if mmGet.defaultExpectation == nil {
+		mmGet.defaultExpectation = &CacheServiceMockGetExpectation{mock: mmGet.mock}
+	}
+	mmGet.defaultExpectation.results = &CacheServiceMockGetResults{p1, b1}
+	return mmGet.mock
+}
+
+// Set uses given function f to mock the CacheService.Get method
+func (mmGet *mCacheServiceMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *CacheServiceMock {
+	if mmGet.defaultExpectation != nil {
+		mmGet.mock.t.Fatalf("Default expectation is already set for the CacheService.Get method")
+	}
+
+	if len(mmGet.expectations) > 0 {
+		mmGet.mock.t.Fatalf("Some expectations are already set for the CacheService.Get method")
+	}
+
+	mmGet.mock.funcGet = f
+	return mmGet.mock
+}
+
+// When sets expectation for the CacheService.Get which will trigger the result defined by the following
+// Then helper
+func (mmGet *mCacheServiceMockGet) When(key string) *CacheServiceMockGetExpectation {
+	if mmGet.mock.funcGet != nil {
+		mmGet.mock.t.Fatalf("CacheServiceMock.Get mock is already set by Set")
+	}
+
+	expectation := &CacheServiceMockGetExpectation{
+		mock:   mmGet.mock,
+		params: &CacheServiceMockGetParams{key},
+	}
+	mmGet.expectations = append(mmGet.expectations, expectation)
+	return expectation
+}
+
+// Then sets up CacheService.Get return parameters for the expectation previously defined by the When method
+func (e *CacheServiceMockGetExpectation) Then(p1 interface{}, b1 bool) *CacheServiceMock {
+	e.results = &CacheServiceMockGetResults{p1, b1}
+	return e.mock
+}
+
+// Times sets number of times CacheService.Get should be invoked
+func (mmGet *mCacheServiceMockGet) Times(n uint64) *mCacheServiceMockGet {
+	if n == 0 {
+		mmGet.mock.t.Fatalf("Times of CacheServiceMock.Get mock can not be zero")
+	}
+	mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
+	return mmGet
+}
+
+func (mmGet *mCacheServiceMockGet) invocationsDone() bool {
+	if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
+		return true
+	}
+
+	totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
+	expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)
+
+	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
+}
+
+// Get implements handler.CacheService
+func (mmGet *CacheServiceMock) Get(key string) (p1 interface{}, b1 bool) {
+	mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
+	defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
+
+	if mmGet.inspectFuncGet != nil {
+		mmGet.inspectFuncGet(key)
+	}
+
+	mm_params := CacheServiceMockGetParams{key}
+
+	// Record call args
+	mmGet.GetMock.mutex.Lock()
+	mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
+	mmGet.GetMock.mutex.Unlock()
+
+	for _, e := range mmGet.GetMock.expectations {
+		if minimock.Equal(*e.params, mm_params) {
+			mm_atomic.AddUint64(&e.Counter, 1)
+			return e.results.p1, e.results.b1
+		}
+	}
+
+	if mmGet.GetMock.defaultExpectation != nil {
+		mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
+		mm_want := mmGet.GetMock.defaultExpectation.params
+		mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs
+
+		mm_got := CacheServiceMockGetParams{key}
+
+		if mm_want_ptrs != nil {
+
+			if mm_want_ptrs.key != nil && !minimock.Equal(*mm_want_ptrs.key, mm_got.key) {
+				mmGet.t.Errorf("CacheServiceMock.Get got unexpected parameter key, want: %#v, got: %#v%s\n", *mm_want_ptrs.key, mm_got.key, minimock.Diff(*mm_want_ptrs.key, mm_got.key))
+			}
+
+		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
+			mmGet.t.Errorf("CacheServiceMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+		}
+
+		mm_results := mmGet.GetMock.defaultExpectation.results
+		if mm_results == nil {
+			mmGet.t.Fatal("No results are set for the CacheServiceMock.Get")
+		}
+		return (*mm_results).p1, (*mm_results).b1
+	}
+	if mmGet.funcGet != nil {
+		return mmGet.funcGet(key)
+	}
+	mmGet.t.Fatalf("Unexpected call to CacheServiceMock.Get. %v", key)
+	return
+}
+
+// GetAfterCounter returns a count of finished CacheServiceMock.Get invocations
+func (mmGet *CacheServiceMock) GetAfterCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
+}
+
+// GetBeforeCounter returns a count of CacheServiceMock.Get invocations
+func (mmGet *CacheServiceMock) GetBeforeCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
+}
+
+// Calls returns a list of arguments used in each call to CacheServiceMock.Get.
+// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
+func (mmGet *mCacheServiceMockGet) Calls() []*CacheServiceMockGetParams {
+	mmGet.mutex.RLock()
+
+	argCopy := make([]*CacheServiceMockGetParams, len(mmGet.callArgs))
+	copy(argCopy, mmGet.callArgs)
+
+	mmGet.mutex.RUnlock()
+
+	return argCopy
+}
+
+// MinimockGetDone returns true if the count of the Get invocations corresponds
+// the number of defined expectations
+func (m *CacheServiceMock) MinimockGetDone() bool {
+	if m.GetMock.optional {
+		// Optional methods provide '0 or more' call count restriction.
+		return true
+	}
+
+	for _, e := range m.GetMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			return false
+		}
+	}
+
+	return m.GetMock.invocationsDone()
+}
+
+// MinimockGetInspect logs each unmet expectation
+func (m *CacheServiceMock) MinimockGetInspect() {
+	for _, e := range m.GetMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			m.t.Errorf("Expected call to CacheServiceMock.Get with params: %#v", *e.params)
+		}
+	}
+
+	afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
+	// if default expectation was set then invocations count should be greater than zero
+	if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
+		if m.GetMock.defaultExpectation.params == nil {
+			m.t.Error("Expected call to CacheServiceMock.Get")
+		} else {
+			m.t.Errorf("Expected call to CacheServiceMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
+		}
+	}
+	// if func was set then invocations count should be greater than zero
+	if m.funcGet != nil && afterGetCounter < 1 {
+		m.t.Error("Expected call to CacheServiceMock.Get")
+	}
+
+	if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
+		m.t.Errorf("Expected %d calls to CacheServiceMock.Get but found %d calls",
+			mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
+	}
+}
+
+type mCacheServiceMockSet struct {
+	optional           bool
+	mock               *CacheServiceMock
+	defaultExpectation *CacheServiceMockSetExpectation
+	expectations       []*CacheServiceMockSetExpectation
+
+	callArgs []*CacheServiceMockSetParams
+	mutex    sync.RWMutex
+
+	expectedInvocations uint64
+}
+
+// CacheServiceMockSetExpectation specifies expectation struct of the CacheService.Set
+type CacheServiceMockSetExpectation struct {
+	mock      *CacheServiceMock
+	params    *CacheServiceMockSetParams
+	paramPtrs *CacheServiceMockSetParamPtrs
+
+	Counter uint64
+}
+
+// CacheServiceMockSetParams contains parameters of the CacheService.Set
+type CacheServiceMockSetParams struct {
+	key   string
+	value interface{}
+}
+
+// CacheServiceMockSetParamPtrs contains pointers to parameters of the CacheService.Set
+type CacheServiceMockSetParamPtrs struct {
+	key   *string
+	value *interface{}
+}
+
+// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
+// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
+// Optional() makes method check to work in '0 or more' mode.
+// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
+// catch the problems when the expected method call is totally skipped during test run.
+func (mmSet *mCacheServiceMockSet) Optional() *mCacheServiceMockSet {
+	mmSet.optional = true
+	return mmSet
+}
+
+// Expect sets up expected params for CacheService.Set
+func (mmSet *mCacheServiceMockSet) Expect(key string, value interface{}) *mCacheServiceMockSet {
+	if mmSet.mock.funcSet != nil {
+		mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Set")
+	}
+
+	if mmSet.defaultExpectation == nil {
+		mmSet.defaultExpectation = &CacheServiceMockSetExpectation{}
+	}
+
+	if mmSet.defaultExpectation.paramPtrs != nil {
+		mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by ExpectParams functions")
+	}
+
+	mmSet.defaultExpectation.params = &CacheServiceMockSetParams{key, value}
+	for _, e := range mmSet.expectations {
+		if minimock.Equal(e.params, mmSet.defaultExpectation.params) {
+			mmSet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSet.defaultExpectation.params)
+		}
+	}
+
+	return mmSet
+}
+
+// ExpectKeyParam1 sets up expected param key for CacheService.Set
+func (mmSet *mCacheServiceMockSet) ExpectKeyParam1(key string) *mCacheServiceMockSet {
+	if mmSet.mock.funcSet != nil {
+		mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Set")
+	}
+
+	if mmSet.defaultExpectation == nil {
+		mmSet.defaultExpectation = &CacheServiceMockSetExpectation{}
+	}
+
+	if mmSet.defaultExpectation.params != nil {
+		mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Expect")
+	}
+
+	if mmSet.defaultExpectation.paramPtrs == nil {
+		mmSet.defaultExpectation.paramPtrs = &CacheServiceMockSetParamPtrs{}
+	}
+	mmSet.defaultExpectation.paramPtrs.key = &key
+
+	return mmSet
+}
+
+// ExpectValueParam2 sets up expected param value for CacheService.Set
+func (mmSet *mCacheServiceMockSet) ExpectValueParam2(value interface{}) *mCacheServiceMockSet {
+	if mmSet.mock.funcSet != nil {
+		mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Set")
+	}
+
+	if mmSet.defaultExpectation == nil {
+		mmSet.defaultExpectation = &CacheServiceMockSetExpectation{}
+	}
+
+	if mmSet.defaultExpectation.params != nil {
+		mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Expect")
+	}
+
+	if mmSet.defaultExpectation.paramPtrs == nil {
+		mmSet.defaultExpectation.paramPtrs = &CacheServiceMockSetParamPtrs{}
+	}
+	mmSet.defaultExpectation.paramPtrs.value = &value
+
+	return mmSet
+}
+
+// Inspect accepts an inspector function that has same arguments as the CacheService.Set
+func (mmSet *mCacheServiceMockSet) Inspect(f func(key string, value interface{})) *mCacheServiceMockSet {
+	if mmSet.mock.inspectFuncSet != nil {
+		mmSet.mock.t.Fatalf("Inspect function is already set for CacheServiceMock.Set")
+	}
+
+	mmSet.mock.inspectFuncSet = f
+
+	return mmSet
+}
+
+// Return sets up results that will be returned by CacheService.Set
+func (mmSet *mCacheServiceMockSet) Return() *CacheServiceMock {
+	if mmSet.mock.funcSet != nil {
+		mmSet.mock.t.Fatalf("CacheServiceMock.Set mock is already set by Set")
+	}
+
+	if mmSet.defaultExpectation == nil {
+		mmSet.defaultExpectation = &CacheServiceMockSetExpectation{mock: mmSet.mock}
+	}
+
+	return mmSet.mock
+}
+
+// Set uses given function f to mock the CacheService.Set method
+func (mmSet *mCacheServiceMockSet) Set(f func(key string, value interface{})) *CacheServiceMock {
+	if mmSet.defaultExpectation != nil {
+		mmSet.mock.t.Fatalf("Default expectation is already set for the CacheService.Set method")
+	}
+
+	if len(mmSet.expectations) > 0 {
+		mmSet.mock.t.Fatalf("Some expectations are already set for the CacheService.Set method")
+	}
+
+	mmSet.mock.funcSet = f
+	return mmSet.mock
+}
+
+// Times sets number of times CacheService.Set should be invoked
+func (mmSet *mCacheServiceMockSet) Times(n uint64) *mCacheServiceMockSet {
+	if n == 0 {
+		mmSet.mock.t.Fatalf("Times of CacheServiceMock.Set mock can not be zero")
+	}
+	mm_atomic.StoreUint64(&mmSet.expectedInvocations, n)
+	return mmSet
+}
+
+func (mmSet *mCacheServiceMockSet) invocationsDone() bool {
+	if len(mmSet.expectations) == 0 && mmSet.defaultExpectation == nil && mmSet.mock.funcSet == nil {
+		return true
+	}
+
+	totalInvocations := mm_atomic.LoadUint64(&mmSet.mock.afterSetCounter)
+	expectedInvocations := mm_atomic.LoadUint64(&mmSet.expectedInvocations)
+
+	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
+}
+
+// Set implements handler.CacheService
+func (mmSet *CacheServiceMock) Set(key string, value interface{}) {
+	mm_atomic.AddUint64(&mmSet.beforeSetCounter, 1)
+	defer mm_atomic.AddUint64(&mmSet.afterSetCounter, 1)
+
+	if mmSet.inspectFuncSet != nil {
+		mmSet.inspectFuncSet(key, value)
+	}
+
+	mm_params := CacheServiceMockSetParams{key, value}
+
+	// Record call args
+	mmSet.SetMock.mutex.Lock()
+	mmSet.SetMock.callArgs = append(mmSet.SetMock.callArgs, &mm_params)
+	mmSet.SetMock.mutex.Unlock()
+
+	for _, e := range mmSet.SetMock.expectations {
+		if minimock.Equal(*e.params, mm_params) {
+			mm_atomic.AddUint64(&e.Counter, 1)
+			return
+		}
+	}
+
+	if mmSet.SetMock.defaultExpectation != nil {
+		mm_atomic.AddUint64(&mmSet.SetMock.defaultExpectation.Counter, 1)
+		mm_want := mmSet.SetMock.defaultExpectation.params
+		mm_want_ptrs := mmSet.SetMock.defaultExpectation.paramPtrs
+
+		mm_got := CacheServiceMockSetParams{key, value}
+
+		if mm_want_ptrs != nil {
+
+			if mm_want_ptrs.key != nil && !minimock.Equal(*mm_want_ptrs.key, mm_got.key) {
+				mmSet.t.Errorf("CacheServiceMock.Set got unexpected parameter key, want: %#v, got: %#v%s\n", *mm_want_ptrs.key, mm_got.key, minimock.Diff(*mm_want_ptrs.key, mm_got.key))
+			}
+
+			if mm_want_ptrs.value != nil && !minimock.Equal(*mm_want_ptrs.value, mm_got.value) {
+				mmSet.t.Errorf("CacheServiceMock.Set got unexpected parameter value, want: %#v, got: %#v%s\n", *mm_want_ptrs.value, mm_got.value, minimock.Diff(*mm_want_ptrs.value, mm_got.value))
+			}
+
+		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
+			mmSet.t.Errorf("CacheServiceMock.Set got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+		}
+
+		return
+
+	}
+	if mmSet.funcSet != nil {
+		mmSet.funcSet(key, value)
+		return
+	}
+	mmSet.t.Fatalf("Unexpected call to CacheServiceMock.Set. %v %v", key, value)
+
+}
+
+// SetAfterCounter returns a count of finished CacheServiceMock.Set invocations
+func (mmSet *CacheServiceMock) SetAfterCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmSet.afterSetCounter)
+}
+
+// SetBeforeCounter returns a count of CacheServiceMock.Set invocations
+func (mmSet *CacheServiceMock) SetBeforeCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmSet.beforeSetCounter)
+}
+
+// Calls returns a list of arguments used in each call to CacheServiceMock.Set.
+// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
+func (mmSet *mCacheServiceMockSet) Calls() []*CacheServiceMockSetParams {
+	mmSet.mutex.RLock()
+
+	argCopy := make([]*CacheServiceMockSetParams, len(mmSet.callArgs))
+	copy(argCopy, mmSet.callArgs)
+
+	mmSet.mutex.RUnlock()
+
+	return argCopy
+}
+
+// MinimockSetDone returns true if the count of the Set invocations corresponds
+// the number of defined expectations
+func (m *CacheServiceMock) MinimockSetDone() bool {
+	if m.SetMock.optional {
+		// Optional methods provide '0 or more' call count restriction.
+		return true
+	}
+
+	for _, e := range m.SetMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			return false
+		}
+	}
+
+	return m.SetMock.invocationsDone()
+}
+
+// MinimockSetInspect logs each unmet expectation
+func (m *CacheServiceMock) MinimockSetInspect() {
+	for _, e := range m.SetMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			m.t.Errorf("Expected call to CacheServiceMock.Set with params: %#v", *e.params)
+		}
+	}
+
+	afterSetCounter := mm_atomic.LoadUint64(&m.afterSetCounter)
+	// if default expectation was set then invocations count should be greater than zero
+	if m.SetMock.defaultExpectation != nil && afterSetCounter < 1 {
+		if m.SetMock.defaultExpectation.params == nil {
+			m.t.Error("Expected call to CacheServiceMock.Set")
+		} else {
+			m.t.Errorf("Expected call to CacheServiceMock.Set with params: %#v", *m.SetMock.defaultExpectation.params)
+		}
+	}
+	// if func was set then invocations count should be greater than zero
+	if m.funcSet != nil && afterSetCounter < 1 {
+		m.t.Error("Expected call to CacheServiceMock.Set")
+	}
+
+	if !m.SetMock.invocationsDone() && afterSetCounter > 0 {
+		m.t.Errorf("Expected %d calls to CacheServiceMock.Set but found %d calls",
+			mm_atomic.LoadUint64(&m.SetMock.expectedInvocations), afterSetCounter)
+	}
+}
+
+// MinimockFinish checks that all mocked methods have been called the expected number of times
+func (m *CacheServiceMock) MinimockFinish() {
+	m.finishOnce.Do(func() {
+		if !m.minimockDone() {
+			m.MinimockGetInspect()
+
+			m.MinimockSetInspect()
+		}
+	})
+}
+
+// MinimockWait waits for all mocked methods to be called the expected number of times
+func (m *CacheServiceMock) MinimockWait(timeout mm_time.Duration) {
+	timeoutCh := mm_time.After(timeout)
+	for {
+		if m.minimockDone() {
+			return
+		}
+		select {
+		case <-timeoutCh:
+			m.MinimockFinish()
+			return
+		case <-mm_time.After(10 * mm_time.Millisecond):
+		}
+	}
+}
+
+func (m *CacheServiceMock) minimockDone() bool {
+	done := true
+	return done &&
+		m.MinimockGetDone() &&
+		m.MinimockSetDone()
+}

+ 700 - 0
internal/services/handler/mocks/tag_repository_minimock.go

@@ -0,0 +1,700 @@
+// Code generated by http://github.com/gojuno/minimock (v3.3.13). DO NOT EDIT.
+
+package mocks
+
+//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler.TagRepository -o tag_repository_minimock.go -n TagRepositoryMock -p mocks
+
+import (
+	"context"
+	"sync"
+	mm_atomic "sync/atomic"
+	mm_time "time"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
+	"github.com/gojuno/minimock/v3"
+)
+
+// TagRepositoryMock implements handler.TagRepository
+type TagRepositoryMock struct {
+	t          minimock.Tester
+	finishOnce sync.Once
+
+	funcGetAllUsed          func(ctx context.Context) (ta1 []models.Tag, err error)
+	inspectFuncGetAllUsed   func(ctx context.Context)
+	afterGetAllUsedCounter  uint64
+	beforeGetAllUsedCounter uint64
+	GetAllUsedMock          mTagRepositoryMockGetAllUsed
+
+	funcGetByURL          func(ctx context.Context, tag string) (tp1 *models.Tag, err error)
+	inspectFuncGetByURL   func(ctx context.Context, tag string)
+	afterGetByURLCounter  uint64
+	beforeGetByURLCounter uint64
+	GetByURLMock          mTagRepositoryMockGetByURL
+}
+
+// NewTagRepositoryMock returns a mock for handler.TagRepository
+func NewTagRepositoryMock(t minimock.Tester) *TagRepositoryMock {
+	m := &TagRepositoryMock{t: t}
+
+	if controller, ok := t.(minimock.MockController); ok {
+		controller.RegisterMocker(m)
+	}
+
+	m.GetAllUsedMock = mTagRepositoryMockGetAllUsed{mock: m}
+	m.GetAllUsedMock.callArgs = []*TagRepositoryMockGetAllUsedParams{}
+
+	m.GetByURLMock = mTagRepositoryMockGetByURL{mock: m}
+	m.GetByURLMock.callArgs = []*TagRepositoryMockGetByURLParams{}
+
+	t.Cleanup(m.MinimockFinish)
+
+	return m
+}
+
+type mTagRepositoryMockGetAllUsed struct {
+	optional           bool
+	mock               *TagRepositoryMock
+	defaultExpectation *TagRepositoryMockGetAllUsedExpectation
+	expectations       []*TagRepositoryMockGetAllUsedExpectation
+
+	callArgs []*TagRepositoryMockGetAllUsedParams
+	mutex    sync.RWMutex
+
+	expectedInvocations uint64
+}
+
+// TagRepositoryMockGetAllUsedExpectation specifies expectation struct of the TagRepository.GetAllUsed
+type TagRepositoryMockGetAllUsedExpectation struct {
+	mock      *TagRepositoryMock
+	params    *TagRepositoryMockGetAllUsedParams
+	paramPtrs *TagRepositoryMockGetAllUsedParamPtrs
+	results   *TagRepositoryMockGetAllUsedResults
+	Counter   uint64
+}
+
+// TagRepositoryMockGetAllUsedParams contains parameters of the TagRepository.GetAllUsed
+type TagRepositoryMockGetAllUsedParams struct {
+	ctx context.Context
+}
+
+// TagRepositoryMockGetAllUsedParamPtrs contains pointers to parameters of the TagRepository.GetAllUsed
+type TagRepositoryMockGetAllUsedParamPtrs struct {
+	ctx *context.Context
+}
+
+// TagRepositoryMockGetAllUsedResults contains results of the TagRepository.GetAllUsed
+type TagRepositoryMockGetAllUsedResults struct {
+	ta1 []models.Tag
+	err error
+}
+
+// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
+// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
+// Optional() makes method check to work in '0 or more' mode.
+// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
+// catch the problems when the expected method call is totally skipped during test run.
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Optional() *mTagRepositoryMockGetAllUsed {
+	mmGetAllUsed.optional = true
+	return mmGetAllUsed
+}
+
+// Expect sets up expected params for TagRepository.GetAllUsed
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Expect(ctx context.Context) *mTagRepositoryMockGetAllUsed {
+	if mmGetAllUsed.mock.funcGetAllUsed != nil {
+		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
+	}
+
+	if mmGetAllUsed.defaultExpectation == nil {
+		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{}
+	}
+
+	if mmGetAllUsed.defaultExpectation.paramPtrs != nil {
+		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by ExpectParams functions")
+	}
+
+	mmGetAllUsed.defaultExpectation.params = &TagRepositoryMockGetAllUsedParams{ctx}
+	for _, e := range mmGetAllUsed.expectations {
+		if minimock.Equal(e.params, mmGetAllUsed.defaultExpectation.params) {
+			mmGetAllUsed.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllUsed.defaultExpectation.params)
+		}
+	}
+
+	return mmGetAllUsed
+}
+
+// ExpectCtxParam1 sets up expected param ctx for TagRepository.GetAllUsed
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) ExpectCtxParam1(ctx context.Context) *mTagRepositoryMockGetAllUsed {
+	if mmGetAllUsed.mock.funcGetAllUsed != nil {
+		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
+	}
+
+	if mmGetAllUsed.defaultExpectation == nil {
+		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{}
+	}
+
+	if mmGetAllUsed.defaultExpectation.params != nil {
+		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Expect")
+	}
+
+	if mmGetAllUsed.defaultExpectation.paramPtrs == nil {
+		mmGetAllUsed.defaultExpectation.paramPtrs = &TagRepositoryMockGetAllUsedParamPtrs{}
+	}
+	mmGetAllUsed.defaultExpectation.paramPtrs.ctx = &ctx
+
+	return mmGetAllUsed
+}
+
+// Inspect accepts an inspector function that has same arguments as the TagRepository.GetAllUsed
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Inspect(f func(ctx context.Context)) *mTagRepositoryMockGetAllUsed {
+	if mmGetAllUsed.mock.inspectFuncGetAllUsed != nil {
+		mmGetAllUsed.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetAllUsed")
+	}
+
+	mmGetAllUsed.mock.inspectFuncGetAllUsed = f
+
+	return mmGetAllUsed
+}
+
+// Return sets up results that will be returned by TagRepository.GetAllUsed
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Return(ta1 []models.Tag, err error) *TagRepositoryMock {
+	if mmGetAllUsed.mock.funcGetAllUsed != nil {
+		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
+	}
+
+	if mmGetAllUsed.defaultExpectation == nil {
+		mmGetAllUsed.defaultExpectation = &TagRepositoryMockGetAllUsedExpectation{mock: mmGetAllUsed.mock}
+	}
+	mmGetAllUsed.defaultExpectation.results = &TagRepositoryMockGetAllUsedResults{ta1, err}
+	return mmGetAllUsed.mock
+}
+
+// Set uses given function f to mock the TagRepository.GetAllUsed method
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Set(f func(ctx context.Context) (ta1 []models.Tag, err error)) *TagRepositoryMock {
+	if mmGetAllUsed.defaultExpectation != nil {
+		mmGetAllUsed.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetAllUsed method")
+	}
+
+	if len(mmGetAllUsed.expectations) > 0 {
+		mmGetAllUsed.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetAllUsed method")
+	}
+
+	mmGetAllUsed.mock.funcGetAllUsed = f
+	return mmGetAllUsed.mock
+}
+
+// When sets expectation for the TagRepository.GetAllUsed which will trigger the result defined by the following
+// Then helper
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) When(ctx context.Context) *TagRepositoryMockGetAllUsedExpectation {
+	if mmGetAllUsed.mock.funcGetAllUsed != nil {
+		mmGetAllUsed.mock.t.Fatalf("TagRepositoryMock.GetAllUsed mock is already set by Set")
+	}
+
+	expectation := &TagRepositoryMockGetAllUsedExpectation{
+		mock:   mmGetAllUsed.mock,
+		params: &TagRepositoryMockGetAllUsedParams{ctx},
+	}
+	mmGetAllUsed.expectations = append(mmGetAllUsed.expectations, expectation)
+	return expectation
+}
+
+// Then sets up TagRepository.GetAllUsed return parameters for the expectation previously defined by the When method
+func (e *TagRepositoryMockGetAllUsedExpectation) Then(ta1 []models.Tag, err error) *TagRepositoryMock {
+	e.results = &TagRepositoryMockGetAllUsedResults{ta1, err}
+	return e.mock
+}
+
+// Times sets number of times TagRepository.GetAllUsed should be invoked
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Times(n uint64) *mTagRepositoryMockGetAllUsed {
+	if n == 0 {
+		mmGetAllUsed.mock.t.Fatalf("Times of TagRepositoryMock.GetAllUsed mock can not be zero")
+	}
+	mm_atomic.StoreUint64(&mmGetAllUsed.expectedInvocations, n)
+	return mmGetAllUsed
+}
+
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) invocationsDone() bool {
+	if len(mmGetAllUsed.expectations) == 0 && mmGetAllUsed.defaultExpectation == nil && mmGetAllUsed.mock.funcGetAllUsed == nil {
+		return true
+	}
+
+	totalInvocations := mm_atomic.LoadUint64(&mmGetAllUsed.mock.afterGetAllUsedCounter)
+	expectedInvocations := mm_atomic.LoadUint64(&mmGetAllUsed.expectedInvocations)
+
+	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
+}
+
+// GetAllUsed implements handler.TagRepository
+func (mmGetAllUsed *TagRepositoryMock) GetAllUsed(ctx context.Context) (ta1 []models.Tag, err error) {
+	mm_atomic.AddUint64(&mmGetAllUsed.beforeGetAllUsedCounter, 1)
+	defer mm_atomic.AddUint64(&mmGetAllUsed.afterGetAllUsedCounter, 1)
+
+	if mmGetAllUsed.inspectFuncGetAllUsed != nil {
+		mmGetAllUsed.inspectFuncGetAllUsed(ctx)
+	}
+
+	mm_params := TagRepositoryMockGetAllUsedParams{ctx}
+
+	// Record call args
+	mmGetAllUsed.GetAllUsedMock.mutex.Lock()
+	mmGetAllUsed.GetAllUsedMock.callArgs = append(mmGetAllUsed.GetAllUsedMock.callArgs, &mm_params)
+	mmGetAllUsed.GetAllUsedMock.mutex.Unlock()
+
+	for _, e := range mmGetAllUsed.GetAllUsedMock.expectations {
+		if minimock.Equal(*e.params, mm_params) {
+			mm_atomic.AddUint64(&e.Counter, 1)
+			return e.results.ta1, e.results.err
+		}
+	}
+
+	if mmGetAllUsed.GetAllUsedMock.defaultExpectation != nil {
+		mm_atomic.AddUint64(&mmGetAllUsed.GetAllUsedMock.defaultExpectation.Counter, 1)
+		mm_want := mmGetAllUsed.GetAllUsedMock.defaultExpectation.params
+		mm_want_ptrs := mmGetAllUsed.GetAllUsedMock.defaultExpectation.paramPtrs
+
+		mm_got := TagRepositoryMockGetAllUsedParams{ctx}
+
+		if mm_want_ptrs != nil {
+
+			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
+				mmGetAllUsed.t.Errorf("TagRepositoryMock.GetAllUsed got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
+			}
+
+		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
+			mmGetAllUsed.t.Errorf("TagRepositoryMock.GetAllUsed got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+		}
+
+		mm_results := mmGetAllUsed.GetAllUsedMock.defaultExpectation.results
+		if mm_results == nil {
+			mmGetAllUsed.t.Fatal("No results are set for the TagRepositoryMock.GetAllUsed")
+		}
+		return (*mm_results).ta1, (*mm_results).err
+	}
+	if mmGetAllUsed.funcGetAllUsed != nil {
+		return mmGetAllUsed.funcGetAllUsed(ctx)
+	}
+	mmGetAllUsed.t.Fatalf("Unexpected call to TagRepositoryMock.GetAllUsed. %v", ctx)
+	return
+}
+
+// GetAllUsedAfterCounter returns a count of finished TagRepositoryMock.GetAllUsed invocations
+func (mmGetAllUsed *TagRepositoryMock) GetAllUsedAfterCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetAllUsed.afterGetAllUsedCounter)
+}
+
+// GetAllUsedBeforeCounter returns a count of TagRepositoryMock.GetAllUsed invocations
+func (mmGetAllUsed *TagRepositoryMock) GetAllUsedBeforeCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetAllUsed.beforeGetAllUsedCounter)
+}
+
+// Calls returns a list of arguments used in each call to TagRepositoryMock.GetAllUsed.
+// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
+func (mmGetAllUsed *mTagRepositoryMockGetAllUsed) Calls() []*TagRepositoryMockGetAllUsedParams {
+	mmGetAllUsed.mutex.RLock()
+
+	argCopy := make([]*TagRepositoryMockGetAllUsedParams, len(mmGetAllUsed.callArgs))
+	copy(argCopy, mmGetAllUsed.callArgs)
+
+	mmGetAllUsed.mutex.RUnlock()
+
+	return argCopy
+}
+
+// MinimockGetAllUsedDone returns true if the count of the GetAllUsed invocations corresponds
+// the number of defined expectations
+func (m *TagRepositoryMock) MinimockGetAllUsedDone() bool {
+	if m.GetAllUsedMock.optional {
+		// Optional methods provide '0 or more' call count restriction.
+		return true
+	}
+
+	for _, e := range m.GetAllUsedMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			return false
+		}
+	}
+
+	return m.GetAllUsedMock.invocationsDone()
+}
+
+// MinimockGetAllUsedInspect logs each unmet expectation
+func (m *TagRepositoryMock) MinimockGetAllUsedInspect() {
+	for _, e := range m.GetAllUsedMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			m.t.Errorf("Expected call to TagRepositoryMock.GetAllUsed with params: %#v", *e.params)
+		}
+	}
+
+	afterGetAllUsedCounter := mm_atomic.LoadUint64(&m.afterGetAllUsedCounter)
+	// if default expectation was set then invocations count should be greater than zero
+	if m.GetAllUsedMock.defaultExpectation != nil && afterGetAllUsedCounter < 1 {
+		if m.GetAllUsedMock.defaultExpectation.params == nil {
+			m.t.Error("Expected call to TagRepositoryMock.GetAllUsed")
+		} else {
+			m.t.Errorf("Expected call to TagRepositoryMock.GetAllUsed with params: %#v", *m.GetAllUsedMock.defaultExpectation.params)
+		}
+	}
+	// if func was set then invocations count should be greater than zero
+	if m.funcGetAllUsed != nil && afterGetAllUsedCounter < 1 {
+		m.t.Error("Expected call to TagRepositoryMock.GetAllUsed")
+	}
+
+	if !m.GetAllUsedMock.invocationsDone() && afterGetAllUsedCounter > 0 {
+		m.t.Errorf("Expected %d calls to TagRepositoryMock.GetAllUsed but found %d calls",
+			mm_atomic.LoadUint64(&m.GetAllUsedMock.expectedInvocations), afterGetAllUsedCounter)
+	}
+}
+
+type mTagRepositoryMockGetByURL struct {
+	optional           bool
+	mock               *TagRepositoryMock
+	defaultExpectation *TagRepositoryMockGetByURLExpectation
+	expectations       []*TagRepositoryMockGetByURLExpectation
+
+	callArgs []*TagRepositoryMockGetByURLParams
+	mutex    sync.RWMutex
+
+	expectedInvocations uint64
+}
+
+// TagRepositoryMockGetByURLExpectation specifies expectation struct of the TagRepository.GetByURL
+type TagRepositoryMockGetByURLExpectation struct {
+	mock      *TagRepositoryMock
+	params    *TagRepositoryMockGetByURLParams
+	paramPtrs *TagRepositoryMockGetByURLParamPtrs
+	results   *TagRepositoryMockGetByURLResults
+	Counter   uint64
+}
+
+// TagRepositoryMockGetByURLParams contains parameters of the TagRepository.GetByURL
+type TagRepositoryMockGetByURLParams struct {
+	ctx context.Context
+	tag string
+}
+
+// TagRepositoryMockGetByURLParamPtrs contains pointers to parameters of the TagRepository.GetByURL
+type TagRepositoryMockGetByURLParamPtrs struct {
+	ctx *context.Context
+	tag *string
+}
+
+// TagRepositoryMockGetByURLResults contains results of the TagRepository.GetByURL
+type TagRepositoryMockGetByURLResults struct {
+	tp1 *models.Tag
+	err error
+}
+
+// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
+// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
+// Optional() makes method check to work in '0 or more' mode.
+// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
+// catch the problems when the expected method call is totally skipped during test run.
+func (mmGetByURL *mTagRepositoryMockGetByURL) Optional() *mTagRepositoryMockGetByURL {
+	mmGetByURL.optional = true
+	return mmGetByURL
+}
+
+// Expect sets up expected params for TagRepository.GetByURL
+func (mmGetByURL *mTagRepositoryMockGetByURL) Expect(ctx context.Context, tag string) *mTagRepositoryMockGetByURL {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	if mmGetByURL.defaultExpectation == nil {
+		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{}
+	}
+
+	if mmGetByURL.defaultExpectation.paramPtrs != nil {
+		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by ExpectParams functions")
+	}
+
+	mmGetByURL.defaultExpectation.params = &TagRepositoryMockGetByURLParams{ctx, tag}
+	for _, e := range mmGetByURL.expectations {
+		if minimock.Equal(e.params, mmGetByURL.defaultExpectation.params) {
+			mmGetByURL.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByURL.defaultExpectation.params)
+		}
+	}
+
+	return mmGetByURL
+}
+
+// ExpectCtxParam1 sets up expected param ctx for TagRepository.GetByURL
+func (mmGetByURL *mTagRepositoryMockGetByURL) ExpectCtxParam1(ctx context.Context) *mTagRepositoryMockGetByURL {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	if mmGetByURL.defaultExpectation == nil {
+		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{}
+	}
+
+	if mmGetByURL.defaultExpectation.params != nil {
+		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Expect")
+	}
+
+	if mmGetByURL.defaultExpectation.paramPtrs == nil {
+		mmGetByURL.defaultExpectation.paramPtrs = &TagRepositoryMockGetByURLParamPtrs{}
+	}
+	mmGetByURL.defaultExpectation.paramPtrs.ctx = &ctx
+
+	return mmGetByURL
+}
+
+// ExpectTagParam2 sets up expected param tag for TagRepository.GetByURL
+func (mmGetByURL *mTagRepositoryMockGetByURL) ExpectTagParam2(tag string) *mTagRepositoryMockGetByURL {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	if mmGetByURL.defaultExpectation == nil {
+		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{}
+	}
+
+	if mmGetByURL.defaultExpectation.params != nil {
+		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Expect")
+	}
+
+	if mmGetByURL.defaultExpectation.paramPtrs == nil {
+		mmGetByURL.defaultExpectation.paramPtrs = &TagRepositoryMockGetByURLParamPtrs{}
+	}
+	mmGetByURL.defaultExpectation.paramPtrs.tag = &tag
+
+	return mmGetByURL
+}
+
+// Inspect accepts an inspector function that has same arguments as the TagRepository.GetByURL
+func (mmGetByURL *mTagRepositoryMockGetByURL) Inspect(f func(ctx context.Context, tag string)) *mTagRepositoryMockGetByURL {
+	if mmGetByURL.mock.inspectFuncGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("Inspect function is already set for TagRepositoryMock.GetByURL")
+	}
+
+	mmGetByURL.mock.inspectFuncGetByURL = f
+
+	return mmGetByURL
+}
+
+// Return sets up results that will be returned by TagRepository.GetByURL
+func (mmGetByURL *mTagRepositoryMockGetByURL) Return(tp1 *models.Tag, err error) *TagRepositoryMock {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	if mmGetByURL.defaultExpectation == nil {
+		mmGetByURL.defaultExpectation = &TagRepositoryMockGetByURLExpectation{mock: mmGetByURL.mock}
+	}
+	mmGetByURL.defaultExpectation.results = &TagRepositoryMockGetByURLResults{tp1, err}
+	return mmGetByURL.mock
+}
+
+// Set uses given function f to mock the TagRepository.GetByURL method
+func (mmGetByURL *mTagRepositoryMockGetByURL) Set(f func(ctx context.Context, tag string) (tp1 *models.Tag, err error)) *TagRepositoryMock {
+	if mmGetByURL.defaultExpectation != nil {
+		mmGetByURL.mock.t.Fatalf("Default expectation is already set for the TagRepository.GetByURL method")
+	}
+
+	if len(mmGetByURL.expectations) > 0 {
+		mmGetByURL.mock.t.Fatalf("Some expectations are already set for the TagRepository.GetByURL method")
+	}
+
+	mmGetByURL.mock.funcGetByURL = f
+	return mmGetByURL.mock
+}
+
+// When sets expectation for the TagRepository.GetByURL which will trigger the result defined by the following
+// Then helper
+func (mmGetByURL *mTagRepositoryMockGetByURL) When(ctx context.Context, tag string) *TagRepositoryMockGetByURLExpectation {
+	if mmGetByURL.mock.funcGetByURL != nil {
+		mmGetByURL.mock.t.Fatalf("TagRepositoryMock.GetByURL mock is already set by Set")
+	}
+
+	expectation := &TagRepositoryMockGetByURLExpectation{
+		mock:   mmGetByURL.mock,
+		params: &TagRepositoryMockGetByURLParams{ctx, tag},
+	}
+	mmGetByURL.expectations = append(mmGetByURL.expectations, expectation)
+	return expectation
+}
+
+// Then sets up TagRepository.GetByURL return parameters for the expectation previously defined by the When method
+func (e *TagRepositoryMockGetByURLExpectation) Then(tp1 *models.Tag, err error) *TagRepositoryMock {
+	e.results = &TagRepositoryMockGetByURLResults{tp1, err}
+	return e.mock
+}
+
+// Times sets number of times TagRepository.GetByURL should be invoked
+func (mmGetByURL *mTagRepositoryMockGetByURL) Times(n uint64) *mTagRepositoryMockGetByURL {
+	if n == 0 {
+		mmGetByURL.mock.t.Fatalf("Times of TagRepositoryMock.GetByURL mock can not be zero")
+	}
+	mm_atomic.StoreUint64(&mmGetByURL.expectedInvocations, n)
+	return mmGetByURL
+}
+
+func (mmGetByURL *mTagRepositoryMockGetByURL) invocationsDone() bool {
+	if len(mmGetByURL.expectations) == 0 && mmGetByURL.defaultExpectation == nil && mmGetByURL.mock.funcGetByURL == nil {
+		return true
+	}
+
+	totalInvocations := mm_atomic.LoadUint64(&mmGetByURL.mock.afterGetByURLCounter)
+	expectedInvocations := mm_atomic.LoadUint64(&mmGetByURL.expectedInvocations)
+
+	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
+}
+
+// GetByURL implements handler.TagRepository
+func (mmGetByURL *TagRepositoryMock) GetByURL(ctx context.Context, tag string) (tp1 *models.Tag, err error) {
+	mm_atomic.AddUint64(&mmGetByURL.beforeGetByURLCounter, 1)
+	defer mm_atomic.AddUint64(&mmGetByURL.afterGetByURLCounter, 1)
+
+	if mmGetByURL.inspectFuncGetByURL != nil {
+		mmGetByURL.inspectFuncGetByURL(ctx, tag)
+	}
+
+	mm_params := TagRepositoryMockGetByURLParams{ctx, tag}
+
+	// Record call args
+	mmGetByURL.GetByURLMock.mutex.Lock()
+	mmGetByURL.GetByURLMock.callArgs = append(mmGetByURL.GetByURLMock.callArgs, &mm_params)
+	mmGetByURL.GetByURLMock.mutex.Unlock()
+
+	for _, e := range mmGetByURL.GetByURLMock.expectations {
+		if minimock.Equal(*e.params, mm_params) {
+			mm_atomic.AddUint64(&e.Counter, 1)
+			return e.results.tp1, e.results.err
+		}
+	}
+
+	if mmGetByURL.GetByURLMock.defaultExpectation != nil {
+		mm_atomic.AddUint64(&mmGetByURL.GetByURLMock.defaultExpectation.Counter, 1)
+		mm_want := mmGetByURL.GetByURLMock.defaultExpectation.params
+		mm_want_ptrs := mmGetByURL.GetByURLMock.defaultExpectation.paramPtrs
+
+		mm_got := TagRepositoryMockGetByURLParams{ctx, tag}
+
+		if mm_want_ptrs != nil {
+
+			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
+				mmGetByURL.t.Errorf("TagRepositoryMock.GetByURL got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
+			}
+
+			if mm_want_ptrs.tag != nil && !minimock.Equal(*mm_want_ptrs.tag, mm_got.tag) {
+				mmGetByURL.t.Errorf("TagRepositoryMock.GetByURL got unexpected parameter tag, want: %#v, got: %#v%s\n", *mm_want_ptrs.tag, mm_got.tag, minimock.Diff(*mm_want_ptrs.tag, mm_got.tag))
+			}
+
+		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
+			mmGetByURL.t.Errorf("TagRepositoryMock.GetByURL got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+		}
+
+		mm_results := mmGetByURL.GetByURLMock.defaultExpectation.results
+		if mm_results == nil {
+			mmGetByURL.t.Fatal("No results are set for the TagRepositoryMock.GetByURL")
+		}
+		return (*mm_results).tp1, (*mm_results).err
+	}
+	if mmGetByURL.funcGetByURL != nil {
+		return mmGetByURL.funcGetByURL(ctx, tag)
+	}
+	mmGetByURL.t.Fatalf("Unexpected call to TagRepositoryMock.GetByURL. %v %v", ctx, tag)
+	return
+}
+
+// GetByURLAfterCounter returns a count of finished TagRepositoryMock.GetByURL invocations
+func (mmGetByURL *TagRepositoryMock) GetByURLAfterCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetByURL.afterGetByURLCounter)
+}
+
+// GetByURLBeforeCounter returns a count of TagRepositoryMock.GetByURL invocations
+func (mmGetByURL *TagRepositoryMock) GetByURLBeforeCounter() uint64 {
+	return mm_atomic.LoadUint64(&mmGetByURL.beforeGetByURLCounter)
+}
+
+// Calls returns a list of arguments used in each call to TagRepositoryMock.GetByURL.
+// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
+func (mmGetByURL *mTagRepositoryMockGetByURL) Calls() []*TagRepositoryMockGetByURLParams {
+	mmGetByURL.mutex.RLock()
+
+	argCopy := make([]*TagRepositoryMockGetByURLParams, len(mmGetByURL.callArgs))
+	copy(argCopy, mmGetByURL.callArgs)
+
+	mmGetByURL.mutex.RUnlock()
+
+	return argCopy
+}
+
+// MinimockGetByURLDone returns true if the count of the GetByURL invocations corresponds
+// the number of defined expectations
+func (m *TagRepositoryMock) MinimockGetByURLDone() bool {
+	if m.GetByURLMock.optional {
+		// Optional methods provide '0 or more' call count restriction.
+		return true
+	}
+
+	for _, e := range m.GetByURLMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			return false
+		}
+	}
+
+	return m.GetByURLMock.invocationsDone()
+}
+
+// MinimockGetByURLInspect logs each unmet expectation
+func (m *TagRepositoryMock) MinimockGetByURLInspect() {
+	for _, e := range m.GetByURLMock.expectations {
+		if mm_atomic.LoadUint64(&e.Counter) < 1 {
+			m.t.Errorf("Expected call to TagRepositoryMock.GetByURL with params: %#v", *e.params)
+		}
+	}
+
+	afterGetByURLCounter := mm_atomic.LoadUint64(&m.afterGetByURLCounter)
+	// if default expectation was set then invocations count should be greater than zero
+	if m.GetByURLMock.defaultExpectation != nil && afterGetByURLCounter < 1 {
+		if m.GetByURLMock.defaultExpectation.params == nil {
+			m.t.Error("Expected call to TagRepositoryMock.GetByURL")
+		} else {
+			m.t.Errorf("Expected call to TagRepositoryMock.GetByURL with params: %#v", *m.GetByURLMock.defaultExpectation.params)
+		}
+	}
+	// if func was set then invocations count should be greater than zero
+	if m.funcGetByURL != nil && afterGetByURLCounter < 1 {
+		m.t.Error("Expected call to TagRepositoryMock.GetByURL")
+	}
+
+	if !m.GetByURLMock.invocationsDone() && afterGetByURLCounter > 0 {
+		m.t.Errorf("Expected %d calls to TagRepositoryMock.GetByURL but found %d calls",
+			mm_atomic.LoadUint64(&m.GetByURLMock.expectedInvocations), afterGetByURLCounter)
+	}
+}
+
+// MinimockFinish checks that all mocked methods have been called the expected number of times
+func (m *TagRepositoryMock) MinimockFinish() {
+	m.finishOnce.Do(func() {
+		if !m.minimockDone() {
+			m.MinimockGetAllUsedInspect()
+
+			m.MinimockGetByURLInspect()
+		}
+	})
+}
+
+// MinimockWait waits for all mocked methods to be called the expected number of times
+func (m *TagRepositoryMock) MinimockWait(timeout mm_time.Duration) {
+	timeoutCh := mm_time.After(timeout)
+	for {
+		if m.minimockDone() {
+			return
+		}
+		select {
+		case <-timeoutCh:
+			m.MinimockFinish()
+			return
+		case <-mm_time.After(10 * mm_time.Millisecond):
+		}
+	}
+}
+
+func (m *TagRepositoryMock) minimockDone() bool {
+	done := true
+	return done &&
+		m.MinimockGetAllUsedDone() &&
+		m.MinimockGetByURLDone()
+}

+ 12 - 8
internal/services/handler/tag.go

@@ -3,23 +3,27 @@ package handler
 import (
 	"database/sql"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/mapper"
 	"github.com/gofiber/fiber/v2"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/mapper"
 )
 
 const tagParam = "tag"
 const tagCacheKey = "tag"
 
-func TagHandler(sp interfaces.ServiceProvider) fiber.Handler {
+func TagHandler(
+	cacheService CacheService,
+	articleRepository ArticleRepository,
+	tagRepository TagRepository,
+) fiber.Handler {
 	return func(fctx *fiber.Ctx) error {
 		ctx := fctx.Context()
 		tagReq := fctx.Params(tagParam)
 
-		renderData, found := sp.GetCacheService().Get(tagCacheKey + tagReq)
+		renderData, found := cacheService.Get(tagCacheKey + tagReq)
 
 		if !found {
-			tag, err := sp.GetTagRepository().GetByURL(ctx, tagReq)
+			tag, err := tagRepository.GetByURL(ctx, tagReq)
 			if err != nil {
 				if err == sql.ErrNoRows {
 					return fiber.ErrNotFound
@@ -27,7 +31,7 @@ func TagHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				return err
 			}
 
-			articles, err := sp.GetArticleRepository().GetPreviewByTagID(ctx, tag.ID)
+			articles, err := articleRepository.GetPreviewByTagID(ctx, tag.ID)
 			if err != nil {
 				return err
 			}
@@ -37,10 +41,10 @@ func TagHandler(sp interfaces.ServiceProvider) fiber.Handler {
 				"headDescription": "статьи с тегом " + tag.Tag,
 				"headKeywords":    "программирование, статьи, блог, " + tag.Tag,
 				"pageTitle":       "Тег<br>" + tag.Tag,
-				"articles":        mapper.ConvertArticlePreviewModelsToDTO(articles),
+				"articles":        mapper.ToArticlePreviewDTOList(articles),
 			}
 
-			sp.GetCacheService().Set(tagCacheKey+tagReq, renderData)
+			cacheService.Set(tagCacheKey+tagReq, renderData)
 		}
 
 		return fctx.Render("tag", renderData, "_layout")

+ 41 - 40
internal/services/handler/tag_test.go

@@ -8,22 +8,18 @@ import (
 	"strconv"
 	"testing"
 
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
-	repositoryMocks "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/repositories/mocks"
-	sp "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/service_provider"
-	cacheMocks "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/cache/mocks"
 	"github.com/brianvoe/gofakeit/v6"
 	"github.com/gofiber/fiber/v2"
 	"github.com/gojuno/minimock/v3"
 	"github.com/stretchr/testify/assert"
+
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/helpers"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/models"
+	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler/mocks"
 )
 
-func Test_TagHandler(t *testing.T) {
-	type cacheMockFunc func(mc *minimock.Controller) interfaces.Cache
-	type tagMockFunc func(mc *minimock.Controller) interfaces.TagRepository
-	type articleMockFunc func(mc *minimock.Controller) interfaces.ArticleRepository
+func TestTagHandler(t *testing.T) {
+	t.Parallel()
 
 	type req struct {
 		method string
@@ -31,7 +27,6 @@ func Test_TagHandler(t *testing.T) {
 	}
 
 	var (
-		mc          = minimock.NewController(t)
 		tagID       = gofakeit.Number(1, 100)
 		publishTime = gofakeit.Date()
 		internalErr = errors.New(gofakeit.Phrase())
@@ -55,9 +50,9 @@ func Test_TagHandler(t *testing.T) {
 		req         req
 		res         int
 		err         error
-		cacheMock   cacheMockFunc
-		tagMock     tagMockFunc
-		articleMock articleMockFunc
+		cacheMock   func(mc *minimock.Controller) CacheService
+		tagMock     func(mc *minimock.Controller) TagRepository
+		articleMock func(mc *minimock.Controller) ArticleRepository
 	}{
 		{
 			name: "positive case",
@@ -67,15 +62,15 @@ func Test_TagHandler(t *testing.T) {
 			},
 			res: fiber.StatusOK,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 				mock.SetMock.Return()
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(tagID), url)
 				}).Return(&tag, nil)
@@ -83,8 +78,8 @@ func Test_TagHandler(t *testing.T) {
 				return mock
 
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 				mock.GetPreviewByTagIDMock.Inspect(func(ctx context.Context, id int) {
 					assert.Equal(mc, tagID, id)
 				}).Return([]models.ArticlePreview{article}, nil)
@@ -100,14 +95,14 @@ func Test_TagHandler(t *testing.T) {
 			},
 			res: fiber.StatusNotFound,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(tagID), url)
 				}).Return(nil, sql.ErrNoRows)
@@ -115,8 +110,8 @@ func Test_TagHandler(t *testing.T) {
 				return mock
 
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				return repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				return mocks.NewArticleRepositoryMock(mc)
 			},
 		},
 		{
@@ -127,22 +122,22 @@ func Test_TagHandler(t *testing.T) {
 			},
 			res: fiber.StatusInternalServerError,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(tagID), url)
 				}).Return(nil, internalErr)
 
 				return mock
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				return repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				return mocks.NewArticleRepositoryMock(mc)
 			},
 		},
 		{
@@ -153,14 +148,14 @@ func Test_TagHandler(t *testing.T) {
 			},
 			res: fiber.StatusInternalServerError,
 			err: nil,
-			cacheMock: func(mc *minimock.Controller) interfaces.Cache {
-				mock := cacheMocks.NewCacheMock(mc)
+			cacheMock: func(mc *minimock.Controller) CacheService {
+				mock := mocks.NewCacheServiceMock(mc)
 				mock.GetMock.Return(nil, false)
 
 				return mock
 			},
-			tagMock: func(mc *minimock.Controller) interfaces.TagRepository {
-				mock := repositoryMocks.NewTagRepositoryMock(mc)
+			tagMock: func(mc *minimock.Controller) TagRepository {
+				mock := mocks.NewTagRepositoryMock(mc)
 				mock.GetByURLMock.Inspect(func(ctx context.Context, url string) {
 					assert.Equal(mc, strconv.Itoa(tagID), url)
 				}).Return(&tag, nil)
@@ -168,8 +163,8 @@ func Test_TagHandler(t *testing.T) {
 				return mock
 
 			},
-			articleMock: func(mc *minimock.Controller) interfaces.ArticleRepository {
-				mock := repositoryMocks.NewArticleRepositoryMock(mc)
+			articleMock: func(mc *minimock.Controller) ArticleRepository {
+				mock := mocks.NewArticleRepositoryMock(mc)
 				mock.GetPreviewByTagIDMock.Inspect(func(ctx context.Context, id int) {
 					assert.Equal(mc, tagID, id)
 				}).Return(nil, internalErr)
@@ -181,11 +176,17 @@ func Test_TagHandler(t *testing.T) {
 
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
+			t.Parallel()
+
+			mc := minimock.NewController(t)
 			fiberApp := fiber.New(helpers.GetFiberTestConfig())
 			fiberReq := httptest.NewRequest(tt.req.method, tt.req.route, nil)
-			serviceProvider := sp.InitMock(tt.cacheMock(mc), tt.tagMock(mc), tt.articleMock(mc))
 
-			fiberApp.Get("/tag/:tag", TagHandler(serviceProvider))
+			fiberApp.Get("/tag/:tag", TagHandler(
+				tt.cacheMock(mc),
+				tt.articleMock(mc),
+				tt.tagMock(mc),
+			))
 
 			fiberRes, fiberErr := fiberApp.Test(fiberReq)
 			assert.Equal(t, tt.res, fiberRes.StatusCode)

+ 19 - 18
internal/services/mailer/mailer.go

@@ -1,18 +1,19 @@
 package mailer
 
-//go:generate mkdir -p mocks
-//go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.Mailer -o ./mocks/ -s "_minimock.go"
-
 import (
 	"fmt"
 	"net/smtp"
 	"strings"
-
-	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces"
 )
 
-type mailer struct {
+type Env interface {
+	SMTPHost() string
+	SMTPPort() string
+	SMTPUser() string
+	SMTPPassword() string
+}
+
+type Service struct {
 	isEnabled bool
 	host      string
 	port      string
@@ -25,17 +26,17 @@ type mailerAuth struct {
 	password string
 }
 
-func Init(env interfaces.Env) (interfaces.Mailer, error) {
-	host := strings.TrimSpace(env.GetSMTPHost())
-	port := strings.TrimSpace(env.GetSMTPPort())
-	user := strings.TrimSpace(env.GetSMTPUser())
-	password := strings.TrimSpace(env.GetSMTPPassword())
+func Init(env Env) (*Service, error) {
+	host := strings.TrimSpace(env.SMTPHost())
+	port := strings.TrimSpace(env.SMTPPort())
+	user := strings.TrimSpace(env.SMTPUser())
+	password := strings.TrimSpace(env.SMTPPassword())
 
 	if host == "" || port == "" || user == "" || password == "" {
-		return &mailer{}, nil
+		return &Service{}, nil
 	}
 
-	return &mailer{
+	return &Service{
 		isEnabled: true,
 		host:      host,
 		port:      port,
@@ -44,7 +45,7 @@ func Init(env interfaces.Env) (interfaces.Mailer, error) {
 	}, nil
 }
 
-func (m mailer) Send(recipient string, subject string, text string) error {
+func (m Service) Send(recipient string, subject string, text string) error {
 	if !m.isEnabled {
 		return nil
 	}
@@ -60,7 +61,7 @@ func (m mailer) Send(recipient string, subject string, text string) error {
 	return smtp.SendMail(m.host+":"+m.port, auth, m.user, to, msg)
 }
 
-func (m mailer) GetMailerAuth(username, password string) smtp.Auth {
+func (m Service) GetMailerAuth(username, password string) smtp.Auth {
 	return &mailerAuth{username, password}
 }
 
@@ -76,10 +77,10 @@ func (a *mailerAuth) Next(fromServer []byte, more bool) ([]byte, error) {
 
 	if more {
 		if command == "username" {
-			return []byte(fmt.Sprintf("%s", a.username)), nil
+			return []byte(a.username), nil
 		}
 		if command == "password" {
-			return []byte(fmt.Sprintf("%s", a.password)), nil
+			return []byte(a.password), nil
 		}
 
 		return nil, fmt.Errorf("unexpected server challenge: %s", command)

+ 0 - 284
internal/services/mailer/mocks/mailer_minimock.go

@@ -1,284 +0,0 @@
-package mocks
-
-// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
-
-//go:generate minimock -i git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/interfaces.Mailer -o ./mocks/mailer_minimock.go -n MailerMock
-
-import (
-	"sync"
-	mm_atomic "sync/atomic"
-	mm_time "time"
-
-	"github.com/gojuno/minimock/v3"
-)
-
-// MailerMock implements interfaces.Mailer
-type MailerMock struct {
-	t minimock.Tester
-
-	funcSend          func(recipient string, subject string, text string) (err error)
-	inspectFuncSend   func(recipient string, subject string, text string)
-	afterSendCounter  uint64
-	beforeSendCounter uint64
-	SendMock          mMailerMockSend
-}
-
-// NewMailerMock returns a mock for interfaces.Mailer
-func NewMailerMock(t minimock.Tester) *MailerMock {
-	m := &MailerMock{t: t}
-	if controller, ok := t.(minimock.MockController); ok {
-		controller.RegisterMocker(m)
-	}
-
-	m.SendMock = mMailerMockSend{mock: m}
-	m.SendMock.callArgs = []*MailerMockSendParams{}
-
-	return m
-}
-
-type mMailerMockSend struct {
-	mock               *MailerMock
-	defaultExpectation *MailerMockSendExpectation
-	expectations       []*MailerMockSendExpectation
-
-	callArgs []*MailerMockSendParams
-	mutex    sync.RWMutex
-}
-
-// MailerMockSendExpectation specifies expectation struct of the Mailer.Send
-type MailerMockSendExpectation struct {
-	mock    *MailerMock
-	params  *MailerMockSendParams
-	results *MailerMockSendResults
-	Counter uint64
-}
-
-// MailerMockSendParams contains parameters of the Mailer.Send
-type MailerMockSendParams struct {
-	recipient string
-	subject   string
-	text      string
-}
-
-// MailerMockSendResults contains results of the Mailer.Send
-type MailerMockSendResults struct {
-	err error
-}
-
-// Expect sets up expected params for Mailer.Send
-func (mmSend *mMailerMockSend) Expect(recipient string, subject string, text string) *mMailerMockSend {
-	if mmSend.mock.funcSend != nil {
-		mmSend.mock.t.Fatalf("MailerMock.Send mock is already set by Set")
-	}
-
-	if mmSend.defaultExpectation == nil {
-		mmSend.defaultExpectation = &MailerMockSendExpectation{}
-	}
-
-	mmSend.defaultExpectation.params = &MailerMockSendParams{recipient, subject, text}
-	for _, e := range mmSend.expectations {
-		if minimock.Equal(e.params, mmSend.defaultExpectation.params) {
-			mmSend.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSend.defaultExpectation.params)
-		}
-	}
-
-	return mmSend
-}
-
-// Inspect accepts an inspector function that has same arguments as the Mailer.Send
-func (mmSend *mMailerMockSend) Inspect(f func(recipient string, subject string, text string)) *mMailerMockSend {
-	if mmSend.mock.inspectFuncSend != nil {
-		mmSend.mock.t.Fatalf("Inspect function is already set for MailerMock.Send")
-	}
-
-	mmSend.mock.inspectFuncSend = f
-
-	return mmSend
-}
-
-// Return sets up results that will be returned by Mailer.Send
-func (mmSend *mMailerMockSend) Return(err error) *MailerMock {
-	if mmSend.mock.funcSend != nil {
-		mmSend.mock.t.Fatalf("MailerMock.Send mock is already set by Set")
-	}
-
-	if mmSend.defaultExpectation == nil {
-		mmSend.defaultExpectation = &MailerMockSendExpectation{mock: mmSend.mock}
-	}
-	mmSend.defaultExpectation.results = &MailerMockSendResults{err}
-	return mmSend.mock
-}
-
-// Set uses given function f to mock the Mailer.Send method
-func (mmSend *mMailerMockSend) Set(f func(recipient string, subject string, text string) (err error)) *MailerMock {
-	if mmSend.defaultExpectation != nil {
-		mmSend.mock.t.Fatalf("Default expectation is already set for the Mailer.Send method")
-	}
-
-	if len(mmSend.expectations) > 0 {
-		mmSend.mock.t.Fatalf("Some expectations are already set for the Mailer.Send method")
-	}
-
-	mmSend.mock.funcSend = f
-	return mmSend.mock
-}
-
-// When sets expectation for the Mailer.Send which will trigger the result defined by the following
-// Then helper
-func (mmSend *mMailerMockSend) When(recipient string, subject string, text string) *MailerMockSendExpectation {
-	if mmSend.mock.funcSend != nil {
-		mmSend.mock.t.Fatalf("MailerMock.Send mock is already set by Set")
-	}
-
-	expectation := &MailerMockSendExpectation{
-		mock:   mmSend.mock,
-		params: &MailerMockSendParams{recipient, subject, text},
-	}
-	mmSend.expectations = append(mmSend.expectations, expectation)
-	return expectation
-}
-
-// Then sets up Mailer.Send return parameters for the expectation previously defined by the When method
-func (e *MailerMockSendExpectation) Then(err error) *MailerMock {
-	e.results = &MailerMockSendResults{err}
-	return e.mock
-}
-
-// Send implements interfaces.Mailer
-func (mmSend *MailerMock) Send(recipient string, subject string, text string) (err error) {
-	mm_atomic.AddUint64(&mmSend.beforeSendCounter, 1)
-	defer mm_atomic.AddUint64(&mmSend.afterSendCounter, 1)
-
-	if mmSend.inspectFuncSend != nil {
-		mmSend.inspectFuncSend(recipient, subject, text)
-	}
-
-	mm_params := &MailerMockSendParams{recipient, subject, text}
-
-	// Record call args
-	mmSend.SendMock.mutex.Lock()
-	mmSend.SendMock.callArgs = append(mmSend.SendMock.callArgs, mm_params)
-	mmSend.SendMock.mutex.Unlock()
-
-	for _, e := range mmSend.SendMock.expectations {
-		if minimock.Equal(e.params, mm_params) {
-			mm_atomic.AddUint64(&e.Counter, 1)
-			return e.results.err
-		}
-	}
-
-	if mmSend.SendMock.defaultExpectation != nil {
-		mm_atomic.AddUint64(&mmSend.SendMock.defaultExpectation.Counter, 1)
-		mm_want := mmSend.SendMock.defaultExpectation.params
-		mm_got := MailerMockSendParams{recipient, subject, text}
-		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmSend.t.Errorf("MailerMock.Send got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
-		}
-
-		mm_results := mmSend.SendMock.defaultExpectation.results
-		if mm_results == nil {
-			mmSend.t.Fatal("No results are set for the MailerMock.Send")
-		}
-		return (*mm_results).err
-	}
-	if mmSend.funcSend != nil {
-		return mmSend.funcSend(recipient, subject, text)
-	}
-	mmSend.t.Fatalf("Unexpected call to MailerMock.Send. %v %v %v", recipient, subject, text)
-	return
-}
-
-// SendAfterCounter returns a count of finished MailerMock.Send invocations
-func (mmSend *MailerMock) SendAfterCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmSend.afterSendCounter)
-}
-
-// SendBeforeCounter returns a count of MailerMock.Send invocations
-func (mmSend *MailerMock) SendBeforeCounter() uint64 {
-	return mm_atomic.LoadUint64(&mmSend.beforeSendCounter)
-}
-
-// Calls returns a list of arguments used in each call to MailerMock.Send.
-// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmSend *mMailerMockSend) Calls() []*MailerMockSendParams {
-	mmSend.mutex.RLock()
-
-	argCopy := make([]*MailerMockSendParams, len(mmSend.callArgs))
-	copy(argCopy, mmSend.callArgs)
-
-	mmSend.mutex.RUnlock()
-
-	return argCopy
-}
-
-// MinimockSendDone returns true if the count of the Send invocations corresponds
-// the number of defined expectations
-func (m *MailerMock) MinimockSendDone() bool {
-	for _, e := range m.SendMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			return false
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.SendMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {
-		return false
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcSend != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {
-		return false
-	}
-	return true
-}
-
-// MinimockSendInspect logs each unmet expectation
-func (m *MailerMock) MinimockSendInspect() {
-	for _, e := range m.SendMock.expectations {
-		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to MailerMock.Send with params: %#v", *e.params)
-		}
-	}
-
-	// if default expectation was set then invocations count should be greater than zero
-	if m.SendMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {
-		if m.SendMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to MailerMock.Send")
-		} else {
-			m.t.Errorf("Expected call to MailerMock.Send with params: %#v", *m.SendMock.defaultExpectation.params)
-		}
-	}
-	// if func was set then invocations count should be greater than zero
-	if m.funcSend != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {
-		m.t.Error("Expected call to MailerMock.Send")
-	}
-}
-
-// MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *MailerMock) MinimockFinish() {
-	if !m.minimockDone() {
-		m.MinimockSendInspect()
-		m.t.FailNow()
-	}
-}
-
-// MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *MailerMock) MinimockWait(timeout mm_time.Duration) {
-	timeoutCh := mm_time.After(timeout)
-	for {
-		if m.minimockDone() {
-			return
-		}
-		select {
-		case <-timeoutCh:
-			m.MinimockFinish()
-			return
-		case <-mm_time.After(10 * mm_time.Millisecond):
-		}
-	}
-}
-
-func (m *MailerMock) minimockDone() bool {
-	done := true
-	return done &&
-		m.MinimockSendDone()
-}