diff --git a/api/admin.yaml b/api/admin.yaml index 4fb0e28..b9e81ac 100644 --- a/api/admin.yaml +++ b/api/admin.yaml @@ -44,6 +44,10 @@ definitions: type: object Game: properties: + google_sheet_id: + type: string + google_sheet_tab_name: + type: string id: type: string name: diff --git a/api/public.yaml b/api/public.yaml index 141d036..a6cad66 100644 --- a/api/public.yaml +++ b/api/public.yaml @@ -44,6 +44,10 @@ definitions: type: object Game: properties: + google_sheet_id: + type: string + google_sheet_tab_name: + type: string id: type: string name: diff --git a/go.mod b/go.mod index 4f13c37..c8d13df 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,19 @@ go 1.22 require ( cloud.google.com/go/maps v1.11.7 github.com/Masterminds/squirrel v1.5.4 + github.com/elliotxx/healthcheck v0.2.1 + github.com/gin-gonic/gin v1.10.0 + github.com/go-playground/validator/v10 v10.22.0 github.com/google/uuid v1.6.0 github.com/jmoiron/sqlx v1.4.0 github.com/lib/pq v1.10.9 + github.com/mattbaird/gochimp v0.0.0-20200820164431-f1082bcdf63f github.com/pkg/errors v0.9.1 github.com/samber/lo v1.46.0 + github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 + github.com/stretchr/testify v1.9.0 google.golang.org/api v0.191.0 google.golang.org/genproto v0.0.0-20240730163845-b1a4ccb954bf ) @@ -24,16 +30,15 @@ require ( github.com/bytedance/sonic/loader v0.2.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gabriel-vasile/mimetype v1.4.5 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.10.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.22.0 // indirect github.com/goccy/go-json v0.10.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/s2a-go v0.1.8 // indirect @@ -47,19 +52,19 @@ require ( github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/magiconair/properties v1.8.7 // indirect - github.com/mattbaird/gochimp v0.0.0-20200820164431-f1082bcdf63f // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect diff --git a/go.sum b/go.sum index ff18eca..f107237 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,4 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14= -cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU= cloud.google.com/go/auth v0.8.0 h1:y8jUJLl/Fg+qNBWxP/Hox2ezJvjkrPb952PC1p0G6A4= cloud.google.com/go/auth v0.8.0/go.mod h1:qGVp/Y3kDRSDZ5gFD/XPUfYQ9xW1iI7q8RIRoCyBbJc= cloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI= @@ -31,6 +29,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/elliotxx/healthcheck v0.2.1 h1:LwhK8Y0C5AGdrywIAG5+ivcNoUI5H4ry4j2ejzGBQaA= +github.com/elliotxx/healthcheck v0.2.1/go.mod h1:y6VW57YGHpqascrlQQBmLciXt66Cfx+l2bnv5fddbtg= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -52,6 +52,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -76,14 +78,16 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/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/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM= github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA= @@ -167,6 +171,7 @@ github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -290,4 +295,3 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/internal/api/admin/server.go b/internal/api/admin/server.go index 8ec4584..fc0c6f0 100644 --- a/internal/api/admin/server.go +++ b/internal/api/admin/server.go @@ -4,6 +4,7 @@ import ( "github.com/gapidobri/prizer/internal/api" "github.com/gapidobri/prizer/internal/service" "github.com/gin-gonic/gin" + "github.com/jmoiron/sqlx" log "github.com/sirupsen/logrus" ) @@ -17,6 +18,7 @@ type Server struct { } func NewServer( + db *sqlx.DB, gameService *service.GameService, userService *service.UserService, prizeService *service.PrizeService, @@ -24,7 +26,7 @@ func NewServer( participationMethodService *service.ParticipationMethodService, ) *Server { return &Server{ - engine: gin.Default(), + engine: api.NewServer(db), gameService: gameService, userService: userService, prizeService: prizeService, @@ -34,8 +36,6 @@ func NewServer( } func (s *Server) Run(address string) { - s.engine.Use(api.ErrorHandler) - s.gameRoutes() s.userRoutes() s.prizeRoutes() diff --git a/internal/api/public/server.go b/internal/api/public/server.go index e50c3f4..0dd6ef3 100644 --- a/internal/api/public/server.go +++ b/internal/api/public/server.go @@ -4,6 +4,7 @@ import ( "github.com/gapidobri/prizer/internal/api" "github.com/gapidobri/prizer/internal/service" "github.com/gin-gonic/gin" + "github.com/jmoiron/sqlx" log "github.com/sirupsen/logrus" ) @@ -12,16 +13,14 @@ type Server struct { gameService *service.GameService } -func NewServer(gameService *service.GameService) *Server { +func NewServer(db *sqlx.DB, gameService *service.GameService) *Server { return &Server{ - engine: gin.Default(), + engine: api.NewServer(db), gameService: gameService, } } func (s *Server) Run(address string) { - s.engine.Use(api.ErrorHandler) - s.participationMethodRoutes() log.Infof("Public API listening on %s", address) diff --git a/internal/api/server.go b/internal/api/server.go new file mode 100644 index 0000000..d5175f3 --- /dev/null +++ b/internal/api/server.go @@ -0,0 +1,22 @@ +package api + +import ( + "github.com/elliotxx/healthcheck" + "github.com/elliotxx/healthcheck/checks" + "github.com/gin-gonic/gin" + "github.com/jmoiron/sqlx" +) + +func NewServer(db *sqlx.DB) *gin.Engine { + engine := gin.Default() + + _ = healthcheck.Register(&engine.RouterGroup) + + engine.GET("/readyz", healthcheck.NewHandler( + healthcheck.NewDefaultHandlerConfigFor(checks.NewSQLCheck(db.DB))), + ) + + engine.Use(ErrorHandler) + + return engine +} diff --git a/internal/app.go b/internal/app.go index 6d67b1b..7774bde 100644 --- a/internal/app.go +++ b/internal/app.go @@ -6,12 +6,12 @@ import ( "github.com/gapidobri/prizer/internal/api/public" "github.com/gapidobri/prizer/internal/database" "github.com/gapidobri/prizer/internal/pkg/clients/addressvalidation" + "github.com/gapidobri/prizer/internal/pkg/clients/mandrill" "github.com/gapidobri/prizer/internal/pkg/clients/sheets" "github.com/gapidobri/prizer/internal/pkg/models/config" "github.com/gapidobri/prizer/internal/service" "github.com/jmoiron/sqlx" _ "github.com/lib/pq" - "github.com/mattbaird/gochimp" log "github.com/sirupsen/logrus" "github.com/spf13/viper" "os" @@ -38,7 +38,7 @@ func Run() { log.WithError(err).Fatal("Failed to create address validation client") } - mandrillClient, err := gochimp.NewMandrill(cfg.Mandrill.ApiKey) + mandrillClient, err := mandrill.NewClient(cfg.Mandrill.ApiKey) if err != nil { log.WithError(err).Fatal("Failed to create mandrill client") } @@ -78,8 +78,9 @@ func Run() { participationMethodService := service.NewParticipationMethodService(participationMethodRepository) // APIs - publicApi := public.NewServer(gameService) + publicApi := public.NewServer(db, gameService) adminApi := admin.NewServer( + db, gameService, userService, prizeService, diff --git a/internal/database/mock_gen.go b/internal/database/mock_gen.go new file mode 100644 index 0000000..327e45c --- /dev/null +++ b/internal/database/mock_gen.go @@ -0,0 +1,1672 @@ +// Code generated by mocktail; DO NOT EDIT. + +package database + +import ( + "context" + "testing" + "time" + + "github.com/gapidobri/prizer/internal/pkg/models/database" + "github.com/stretchr/testify/mock" +) + +// drawMethodRepositoryMock mock of DrawMethodRepository. +type drawMethodRepositoryMock struct{ mock.Mock } + +// NewDrawMethodRepositoryMock creates a new drawMethodRepositoryMock. +func NewDrawMethodRepositoryMock(tb testing.TB) *drawMethodRepositoryMock { + tb.Helper() + + m := &drawMethodRepositoryMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *drawMethodRepositoryMock) GetDrawMethods(_ context.Context, gameId string, filter database.GetDrawMethodsFilter) ([]database.DrawMethod, error) { + _ret := _m.Called(gameId, filter) + + if _rf, ok := _ret.Get(0).(func(string, database.GetDrawMethodsFilter) ([]database.DrawMethod, error)); ok { + return _rf(gameId, filter) + } + + _ra0, _ := _ret.Get(0).([]database.DrawMethod) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *drawMethodRepositoryMock) OnGetDrawMethods(gameId string, filter database.GetDrawMethodsFilter) *drawMethodRepositoryGetDrawMethodsCall { + return &drawMethodRepositoryGetDrawMethodsCall{Call: _m.Mock.On("GetDrawMethods", gameId, filter), Parent: _m} +} + +func (_m *drawMethodRepositoryMock) OnGetDrawMethodsRaw(gameId interface{}, filter interface{}) *drawMethodRepositoryGetDrawMethodsCall { + return &drawMethodRepositoryGetDrawMethodsCall{Call: _m.Mock.On("GetDrawMethods", gameId, filter), Parent: _m} +} + +type drawMethodRepositoryGetDrawMethodsCall struct { + *mock.Call + Parent *drawMethodRepositoryMock +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) Panic(msg string) *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) Once() *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) Twice() *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) Times(i int) *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) WaitUntil(w <-chan time.Time) *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) After(d time.Duration) *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) Run(fn func(args mock.Arguments)) *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) Maybe() *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) TypedReturns(a []database.DrawMethod, b error) *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) ReturnsFn(fn func(string, database.GetDrawMethodsFilter) ([]database.DrawMethod, error)) *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) TypedRun(fn func(string, database.GetDrawMethodsFilter)) *drawMethodRepositoryGetDrawMethodsCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _gameId := args.String(0) + _filter, _ := args.Get(1).(database.GetDrawMethodsFilter) + fn(_gameId, _filter) + }) + return _c +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) OnGetDrawMethods(gameId string, filter database.GetDrawMethodsFilter) *drawMethodRepositoryGetDrawMethodsCall { + return _c.Parent.OnGetDrawMethods(gameId, filter) +} + +func (_c *drawMethodRepositoryGetDrawMethodsCall) OnGetDrawMethodsRaw(gameId interface{}, filter interface{}) *drawMethodRepositoryGetDrawMethodsCall { + return _c.Parent.OnGetDrawMethodsRaw(gameId, filter) +} + +// gameRepositoryMock mock of GameRepository. +type gameRepositoryMock struct{ mock.Mock } + +// NewGameRepositoryMock creates a new gameRepositoryMock. +func NewGameRepositoryMock(tb testing.TB) *gameRepositoryMock { + tb.Helper() + + m := &gameRepositoryMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *gameRepositoryMock) GetGame(_ context.Context, gameId string) (*database.Game, error) { + _ret := _m.Called(gameId) + + if _rf, ok := _ret.Get(0).(func(string) (*database.Game, error)); ok { + return _rf(gameId) + } + + _ra0, _ := _ret.Get(0).(*database.Game) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *gameRepositoryMock) OnGetGame(gameId string) *gameRepositoryGetGameCall { + return &gameRepositoryGetGameCall{Call: _m.Mock.On("GetGame", gameId), Parent: _m} +} + +func (_m *gameRepositoryMock) OnGetGameRaw(gameId interface{}) *gameRepositoryGetGameCall { + return &gameRepositoryGetGameCall{Call: _m.Mock.On("GetGame", gameId), Parent: _m} +} + +type gameRepositoryGetGameCall struct { + *mock.Call + Parent *gameRepositoryMock +} + +func (_c *gameRepositoryGetGameCall) Panic(msg string) *gameRepositoryGetGameCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *gameRepositoryGetGameCall) Once() *gameRepositoryGetGameCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *gameRepositoryGetGameCall) Twice() *gameRepositoryGetGameCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *gameRepositoryGetGameCall) Times(i int) *gameRepositoryGetGameCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *gameRepositoryGetGameCall) WaitUntil(w <-chan time.Time) *gameRepositoryGetGameCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *gameRepositoryGetGameCall) After(d time.Duration) *gameRepositoryGetGameCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *gameRepositoryGetGameCall) Run(fn func(args mock.Arguments)) *gameRepositoryGetGameCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *gameRepositoryGetGameCall) Maybe() *gameRepositoryGetGameCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *gameRepositoryGetGameCall) TypedReturns(a *database.Game, b error) *gameRepositoryGetGameCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *gameRepositoryGetGameCall) ReturnsFn(fn func(string) (*database.Game, error)) *gameRepositoryGetGameCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *gameRepositoryGetGameCall) TypedRun(fn func(string)) *gameRepositoryGetGameCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _gameId := args.String(0) + fn(_gameId) + }) + return _c +} + +func (_c *gameRepositoryGetGameCall) OnGetGame(gameId string) *gameRepositoryGetGameCall { + return _c.Parent.OnGetGame(gameId) +} + +func (_c *gameRepositoryGetGameCall) OnGetGames() *gameRepositoryGetGamesCall { + return _c.Parent.OnGetGames() +} + +func (_c *gameRepositoryGetGameCall) OnGetGameRaw(gameId interface{}) *gameRepositoryGetGameCall { + return _c.Parent.OnGetGameRaw(gameId) +} + +func (_c *gameRepositoryGetGameCall) OnGetGamesRaw() *gameRepositoryGetGamesCall { + return _c.Parent.OnGetGamesRaw() +} + +func (_m *gameRepositoryMock) GetGames(_ context.Context) ([]database.Game, error) { + _ret := _m.Called() + + if _rf, ok := _ret.Get(0).(func() ([]database.Game, error)); ok { + return _rf() + } + + _ra0, _ := _ret.Get(0).([]database.Game) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *gameRepositoryMock) OnGetGames() *gameRepositoryGetGamesCall { + return &gameRepositoryGetGamesCall{Call: _m.Mock.On("GetGames"), Parent: _m} +} + +func (_m *gameRepositoryMock) OnGetGamesRaw() *gameRepositoryGetGamesCall { + return &gameRepositoryGetGamesCall{Call: _m.Mock.On("GetGames"), Parent: _m} +} + +type gameRepositoryGetGamesCall struct { + *mock.Call + Parent *gameRepositoryMock +} + +func (_c *gameRepositoryGetGamesCall) Panic(msg string) *gameRepositoryGetGamesCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *gameRepositoryGetGamesCall) Once() *gameRepositoryGetGamesCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *gameRepositoryGetGamesCall) Twice() *gameRepositoryGetGamesCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *gameRepositoryGetGamesCall) Times(i int) *gameRepositoryGetGamesCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *gameRepositoryGetGamesCall) WaitUntil(w <-chan time.Time) *gameRepositoryGetGamesCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *gameRepositoryGetGamesCall) After(d time.Duration) *gameRepositoryGetGamesCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *gameRepositoryGetGamesCall) Run(fn func(args mock.Arguments)) *gameRepositoryGetGamesCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *gameRepositoryGetGamesCall) Maybe() *gameRepositoryGetGamesCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *gameRepositoryGetGamesCall) TypedReturns(a []database.Game, b error) *gameRepositoryGetGamesCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *gameRepositoryGetGamesCall) ReturnsFn(fn func() ([]database.Game, error)) *gameRepositoryGetGamesCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *gameRepositoryGetGamesCall) TypedRun(fn func()) *gameRepositoryGetGamesCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + fn() + }) + return _c +} + +func (_c *gameRepositoryGetGamesCall) OnGetGame(gameId string) *gameRepositoryGetGameCall { + return _c.Parent.OnGetGame(gameId) +} + +func (_c *gameRepositoryGetGamesCall) OnGetGames() *gameRepositoryGetGamesCall { + return _c.Parent.OnGetGames() +} + +func (_c *gameRepositoryGetGamesCall) OnGetGameRaw(gameId interface{}) *gameRepositoryGetGameCall { + return _c.Parent.OnGetGameRaw(gameId) +} + +func (_c *gameRepositoryGetGamesCall) OnGetGamesRaw() *gameRepositoryGetGamesCall { + return _c.Parent.OnGetGamesRaw() +} + +// mailTemplateRepositoryMock mock of MailTemplateRepository. +type mailTemplateRepositoryMock struct{ mock.Mock } + +// NewMailTemplateRepositoryMock creates a new mailTemplateRepositoryMock. +func NewMailTemplateRepositoryMock(tb testing.TB) *mailTemplateRepositoryMock { + tb.Helper() + + m := &mailTemplateRepositoryMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *mailTemplateRepositoryMock) GetMailTemplate(_ context.Context, mailTemplateId string) (*database.MailTemplate, error) { + _ret := _m.Called(mailTemplateId) + + if _rf, ok := _ret.Get(0).(func(string) (*database.MailTemplate, error)); ok { + return _rf(mailTemplateId) + } + + _ra0, _ := _ret.Get(0).(*database.MailTemplate) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *mailTemplateRepositoryMock) OnGetMailTemplate(mailTemplateId string) *mailTemplateRepositoryGetMailTemplateCall { + return &mailTemplateRepositoryGetMailTemplateCall{Call: _m.Mock.On("GetMailTemplate", mailTemplateId), Parent: _m} +} + +func (_m *mailTemplateRepositoryMock) OnGetMailTemplateRaw(mailTemplateId interface{}) *mailTemplateRepositoryGetMailTemplateCall { + return &mailTemplateRepositoryGetMailTemplateCall{Call: _m.Mock.On("GetMailTemplate", mailTemplateId), Parent: _m} +} + +type mailTemplateRepositoryGetMailTemplateCall struct { + *mock.Call + Parent *mailTemplateRepositoryMock +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) Panic(msg string) *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) Once() *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) Twice() *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) Times(i int) *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) WaitUntil(w <-chan time.Time) *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) After(d time.Duration) *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) Run(fn func(args mock.Arguments)) *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) Maybe() *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) TypedReturns(a *database.MailTemplate, b error) *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) ReturnsFn(fn func(string) (*database.MailTemplate, error)) *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) TypedRun(fn func(string)) *mailTemplateRepositoryGetMailTemplateCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _mailTemplateId := args.String(0) + fn(_mailTemplateId) + }) + return _c +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) OnGetMailTemplate(mailTemplateId string) *mailTemplateRepositoryGetMailTemplateCall { + return _c.Parent.OnGetMailTemplate(mailTemplateId) +} + +func (_c *mailTemplateRepositoryGetMailTemplateCall) OnGetMailTemplateRaw(mailTemplateId interface{}) *mailTemplateRepositoryGetMailTemplateCall { + return _c.Parent.OnGetMailTemplateRaw(mailTemplateId) +} + +// participationRepositoryMock mock of ParticipationRepository. +type participationRepositoryMock struct{ mock.Mock } + +// NewParticipationRepositoryMock creates a new participationRepositoryMock. +func NewParticipationRepositoryMock(tb testing.TB) *participationRepositoryMock { + tb.Helper() + + m := &participationRepositoryMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *participationRepositoryMock) CreateParticipation(_ context.Context, createParticipation database.CreateParticipation) (*database.Participation, error) { + _ret := _m.Called(createParticipation) + + if _rf, ok := _ret.Get(0).(func(database.CreateParticipation) (*database.Participation, error)); ok { + return _rf(createParticipation) + } + + _ra0, _ := _ret.Get(0).(*database.Participation) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *participationRepositoryMock) OnCreateParticipation(createParticipation database.CreateParticipation) *participationRepositoryCreateParticipationCall { + return &participationRepositoryCreateParticipationCall{Call: _m.Mock.On("CreateParticipation", createParticipation), Parent: _m} +} + +func (_m *participationRepositoryMock) OnCreateParticipationRaw(createParticipation interface{}) *participationRepositoryCreateParticipationCall { + return &participationRepositoryCreateParticipationCall{Call: _m.Mock.On("CreateParticipation", createParticipation), Parent: _m} +} + +type participationRepositoryCreateParticipationCall struct { + *mock.Call + Parent *participationRepositoryMock +} + +func (_c *participationRepositoryCreateParticipationCall) Panic(msg string) *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) Once() *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) Twice() *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) Times(i int) *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) WaitUntil(w <-chan time.Time) *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) After(d time.Duration) *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) Run(fn func(args mock.Arguments)) *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) Maybe() *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) TypedReturns(a *database.Participation, b error) *participationRepositoryCreateParticipationCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) ReturnsFn(fn func(database.CreateParticipation) (*database.Participation, error)) *participationRepositoryCreateParticipationCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) TypedRun(fn func(database.CreateParticipation)) *participationRepositoryCreateParticipationCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _createParticipation, _ := args.Get(0).(database.CreateParticipation) + fn(_createParticipation) + }) + return _c +} + +func (_c *participationRepositoryCreateParticipationCall) OnCreateParticipation(createParticipation database.CreateParticipation) *participationRepositoryCreateParticipationCall { + return _c.Parent.OnCreateParticipation(createParticipation) +} + +func (_c *participationRepositoryCreateParticipationCall) OnGetParticipations(filter database.GetParticipationsFilter) *participationRepositoryGetParticipationsCall { + return _c.Parent.OnGetParticipations(filter) +} + +func (_c *participationRepositoryCreateParticipationCall) OnCreateParticipationRaw(createParticipation interface{}) *participationRepositoryCreateParticipationCall { + return _c.Parent.OnCreateParticipationRaw(createParticipation) +} + +func (_c *participationRepositoryCreateParticipationCall) OnGetParticipationsRaw(filter interface{}) *participationRepositoryGetParticipationsCall { + return _c.Parent.OnGetParticipationsRaw(filter) +} + +func (_m *participationRepositoryMock) GetParticipations(_ context.Context, filter database.GetParticipationsFilter) ([]database.Participation, error) { + _ret := _m.Called(filter) + + if _rf, ok := _ret.Get(0).(func(database.GetParticipationsFilter) ([]database.Participation, error)); ok { + return _rf(filter) + } + + _ra0, _ := _ret.Get(0).([]database.Participation) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *participationRepositoryMock) OnGetParticipations(filter database.GetParticipationsFilter) *participationRepositoryGetParticipationsCall { + return &participationRepositoryGetParticipationsCall{Call: _m.Mock.On("GetParticipations", filter), Parent: _m} +} + +func (_m *participationRepositoryMock) OnGetParticipationsRaw(filter interface{}) *participationRepositoryGetParticipationsCall { + return &participationRepositoryGetParticipationsCall{Call: _m.Mock.On("GetParticipations", filter), Parent: _m} +} + +type participationRepositoryGetParticipationsCall struct { + *mock.Call + Parent *participationRepositoryMock +} + +func (_c *participationRepositoryGetParticipationsCall) Panic(msg string) *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) Once() *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) Twice() *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) Times(i int) *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) WaitUntil(w <-chan time.Time) *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) After(d time.Duration) *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) Run(fn func(args mock.Arguments)) *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) Maybe() *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) TypedReturns(a []database.Participation, b error) *participationRepositoryGetParticipationsCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) ReturnsFn(fn func(database.GetParticipationsFilter) ([]database.Participation, error)) *participationRepositoryGetParticipationsCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) TypedRun(fn func(database.GetParticipationsFilter)) *participationRepositoryGetParticipationsCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _filter, _ := args.Get(0).(database.GetParticipationsFilter) + fn(_filter) + }) + return _c +} + +func (_c *participationRepositoryGetParticipationsCall) OnCreateParticipation(createParticipation database.CreateParticipation) *participationRepositoryCreateParticipationCall { + return _c.Parent.OnCreateParticipation(createParticipation) +} + +func (_c *participationRepositoryGetParticipationsCall) OnGetParticipations(filter database.GetParticipationsFilter) *participationRepositoryGetParticipationsCall { + return _c.Parent.OnGetParticipations(filter) +} + +func (_c *participationRepositoryGetParticipationsCall) OnCreateParticipationRaw(createParticipation interface{}) *participationRepositoryCreateParticipationCall { + return _c.Parent.OnCreateParticipationRaw(createParticipation) +} + +func (_c *participationRepositoryGetParticipationsCall) OnGetParticipationsRaw(filter interface{}) *participationRepositoryGetParticipationsCall { + return _c.Parent.OnGetParticipationsRaw(filter) +} + +// participationMethodRepositoryMock mock of ParticipationMethodRepository. +type participationMethodRepositoryMock struct{ mock.Mock } + +// NewParticipationMethodRepositoryMock creates a new participationMethodRepositoryMock. +func NewParticipationMethodRepositoryMock(tb testing.TB) *participationMethodRepositoryMock { + tb.Helper() + + m := &participationMethodRepositoryMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *participationMethodRepositoryMock) GetParticipationMethod(_ context.Context, participationMethodId string) (*database.ParticipationMethod, error) { + _ret := _m.Called(participationMethodId) + + if _rf, ok := _ret.Get(0).(func(string) (*database.ParticipationMethod, error)); ok { + return _rf(participationMethodId) + } + + _ra0, _ := _ret.Get(0).(*database.ParticipationMethod) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *participationMethodRepositoryMock) OnGetParticipationMethod(participationMethodId string) *participationMethodRepositoryGetParticipationMethodCall { + return &participationMethodRepositoryGetParticipationMethodCall{Call: _m.Mock.On("GetParticipationMethod", participationMethodId), Parent: _m} +} + +func (_m *participationMethodRepositoryMock) OnGetParticipationMethodRaw(participationMethodId interface{}) *participationMethodRepositoryGetParticipationMethodCall { + return &participationMethodRepositoryGetParticipationMethodCall{Call: _m.Mock.On("GetParticipationMethod", participationMethodId), Parent: _m} +} + +type participationMethodRepositoryGetParticipationMethodCall struct { + *mock.Call + Parent *participationMethodRepositoryMock +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) Panic(msg string) *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) Once() *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) Twice() *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) Times(i int) *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) WaitUntil(w <-chan time.Time) *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) After(d time.Duration) *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) Run(fn func(args mock.Arguments)) *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) Maybe() *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) TypedReturns(a *database.ParticipationMethod, b error) *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) ReturnsFn(fn func(string) (*database.ParticipationMethod, error)) *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) TypedRun(fn func(string)) *participationMethodRepositoryGetParticipationMethodCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _participationMethodId := args.String(0) + fn(_participationMethodId) + }) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) OnGetParticipationMethod(participationMethodId string) *participationMethodRepositoryGetParticipationMethodCall { + return _c.Parent.OnGetParticipationMethod(participationMethodId) +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) OnGetParticipationMethods(filter database.GetParticipationMethodsFilter) *participationMethodRepositoryGetParticipationMethodsCall { + return _c.Parent.OnGetParticipationMethods(filter) +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) OnGetParticipationMethodRaw(participationMethodId interface{}) *participationMethodRepositoryGetParticipationMethodCall { + return _c.Parent.OnGetParticipationMethodRaw(participationMethodId) +} + +func (_c *participationMethodRepositoryGetParticipationMethodCall) OnGetParticipationMethodsRaw(filter interface{}) *participationMethodRepositoryGetParticipationMethodsCall { + return _c.Parent.OnGetParticipationMethodsRaw(filter) +} + +func (_m *participationMethodRepositoryMock) GetParticipationMethods(_ context.Context, filter database.GetParticipationMethodsFilter) ([]database.ParticipationMethod, error) { + _ret := _m.Called(filter) + + if _rf, ok := _ret.Get(0).(func(database.GetParticipationMethodsFilter) ([]database.ParticipationMethod, error)); ok { + return _rf(filter) + } + + _ra0, _ := _ret.Get(0).([]database.ParticipationMethod) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *participationMethodRepositoryMock) OnGetParticipationMethods(filter database.GetParticipationMethodsFilter) *participationMethodRepositoryGetParticipationMethodsCall { + return &participationMethodRepositoryGetParticipationMethodsCall{Call: _m.Mock.On("GetParticipationMethods", filter), Parent: _m} +} + +func (_m *participationMethodRepositoryMock) OnGetParticipationMethodsRaw(filter interface{}) *participationMethodRepositoryGetParticipationMethodsCall { + return &participationMethodRepositoryGetParticipationMethodsCall{Call: _m.Mock.On("GetParticipationMethods", filter), Parent: _m} +} + +type participationMethodRepositoryGetParticipationMethodsCall struct { + *mock.Call + Parent *participationMethodRepositoryMock +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) Panic(msg string) *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) Once() *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) Twice() *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) Times(i int) *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) WaitUntil(w <-chan time.Time) *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) After(d time.Duration) *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) Run(fn func(args mock.Arguments)) *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) Maybe() *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) TypedReturns(a []database.ParticipationMethod, b error) *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) ReturnsFn(fn func(database.GetParticipationMethodsFilter) ([]database.ParticipationMethod, error)) *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) TypedRun(fn func(database.GetParticipationMethodsFilter)) *participationMethodRepositoryGetParticipationMethodsCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _filter, _ := args.Get(0).(database.GetParticipationMethodsFilter) + fn(_filter) + }) + return _c +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) OnGetParticipationMethod(participationMethodId string) *participationMethodRepositoryGetParticipationMethodCall { + return _c.Parent.OnGetParticipationMethod(participationMethodId) +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) OnGetParticipationMethods(filter database.GetParticipationMethodsFilter) *participationMethodRepositoryGetParticipationMethodsCall { + return _c.Parent.OnGetParticipationMethods(filter) +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) OnGetParticipationMethodRaw(participationMethodId interface{}) *participationMethodRepositoryGetParticipationMethodCall { + return _c.Parent.OnGetParticipationMethodRaw(participationMethodId) +} + +func (_c *participationMethodRepositoryGetParticipationMethodsCall) OnGetParticipationMethodsRaw(filter interface{}) *participationMethodRepositoryGetParticipationMethodsCall { + return _c.Parent.OnGetParticipationMethodsRaw(filter) +} + +// prizeRepositoryMock mock of PrizeRepository. +type prizeRepositoryMock struct{ mock.Mock } + +// NewPrizeRepositoryMock creates a new prizeRepositoryMock. +func NewPrizeRepositoryMock(tb testing.TB) *prizeRepositoryMock { + tb.Helper() + + m := &prizeRepositoryMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *prizeRepositoryMock) GetPrizes(_ context.Context, filter database.GetPrizesFilter) ([]database.Prize, error) { + _ret := _m.Called(filter) + + if _rf, ok := _ret.Get(0).(func(database.GetPrizesFilter) ([]database.Prize, error)); ok { + return _rf(filter) + } + + _ra0, _ := _ret.Get(0).([]database.Prize) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *prizeRepositoryMock) OnGetPrizes(filter database.GetPrizesFilter) *prizeRepositoryGetPrizesCall { + return &prizeRepositoryGetPrizesCall{Call: _m.Mock.On("GetPrizes", filter), Parent: _m} +} + +func (_m *prizeRepositoryMock) OnGetPrizesRaw(filter interface{}) *prizeRepositoryGetPrizesCall { + return &prizeRepositoryGetPrizesCall{Call: _m.Mock.On("GetPrizes", filter), Parent: _m} +} + +type prizeRepositoryGetPrizesCall struct { + *mock.Call + Parent *prizeRepositoryMock +} + +func (_c *prizeRepositoryGetPrizesCall) Panic(msg string) *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) Once() *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) Twice() *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) Times(i int) *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) WaitUntil(w <-chan time.Time) *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) After(d time.Duration) *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) Run(fn func(args mock.Arguments)) *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) Maybe() *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) TypedReturns(a []database.Prize, b error) *prizeRepositoryGetPrizesCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) ReturnsFn(fn func(database.GetPrizesFilter) ([]database.Prize, error)) *prizeRepositoryGetPrizesCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) TypedRun(fn func(database.GetPrizesFilter)) *prizeRepositoryGetPrizesCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _filter, _ := args.Get(0).(database.GetPrizesFilter) + fn(_filter) + }) + return _c +} + +func (_c *prizeRepositoryGetPrizesCall) OnGetPrizes(filter database.GetPrizesFilter) *prizeRepositoryGetPrizesCall { + return _c.Parent.OnGetPrizes(filter) +} + +func (_c *prizeRepositoryGetPrizesCall) OnGetPrizesRaw(filter interface{}) *prizeRepositoryGetPrizesCall { + return _c.Parent.OnGetPrizesRaw(filter) +} + +// userRepositoryMock mock of UserRepository. +type userRepositoryMock struct{ mock.Mock } + +// NewUserRepositoryMock creates a new userRepositoryMock. +func NewUserRepositoryMock(tb testing.TB) *userRepositoryMock { + tb.Helper() + + m := &userRepositoryMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *userRepositoryMock) CreateUser(_ context.Context, user database.CreateUser) (*database.User, error) { + _ret := _m.Called(user) + + if _rf, ok := _ret.Get(0).(func(database.CreateUser) (*database.User, error)); ok { + return _rf(user) + } + + _ra0, _ := _ret.Get(0).(*database.User) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *userRepositoryMock) OnCreateUser(user database.CreateUser) *userRepositoryCreateUserCall { + return &userRepositoryCreateUserCall{Call: _m.Mock.On("CreateUser", user), Parent: _m} +} + +func (_m *userRepositoryMock) OnCreateUserRaw(user interface{}) *userRepositoryCreateUserCall { + return &userRepositoryCreateUserCall{Call: _m.Mock.On("CreateUser", user), Parent: _m} +} + +type userRepositoryCreateUserCall struct { + *mock.Call + Parent *userRepositoryMock +} + +func (_c *userRepositoryCreateUserCall) Panic(msg string) *userRepositoryCreateUserCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *userRepositoryCreateUserCall) Once() *userRepositoryCreateUserCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *userRepositoryCreateUserCall) Twice() *userRepositoryCreateUserCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *userRepositoryCreateUserCall) Times(i int) *userRepositoryCreateUserCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *userRepositoryCreateUserCall) WaitUntil(w <-chan time.Time) *userRepositoryCreateUserCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *userRepositoryCreateUserCall) After(d time.Duration) *userRepositoryCreateUserCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *userRepositoryCreateUserCall) Run(fn func(args mock.Arguments)) *userRepositoryCreateUserCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *userRepositoryCreateUserCall) Maybe() *userRepositoryCreateUserCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *userRepositoryCreateUserCall) TypedReturns(a *database.User, b error) *userRepositoryCreateUserCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *userRepositoryCreateUserCall) ReturnsFn(fn func(database.CreateUser) (*database.User, error)) *userRepositoryCreateUserCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *userRepositoryCreateUserCall) TypedRun(fn func(database.CreateUser)) *userRepositoryCreateUserCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _user, _ := args.Get(0).(database.CreateUser) + fn(_user) + }) + return _c +} + +func (_c *userRepositoryCreateUserCall) OnCreateUser(user database.CreateUser) *userRepositoryCreateUserCall { + return _c.Parent.OnCreateUser(user) +} + +func (_c *userRepositoryCreateUserCall) OnGetUser(userId string) *userRepositoryGetUserCall { + return _c.Parent.OnGetUser(userId) +} + +func (_c *userRepositoryCreateUserCall) OnGetUserFromFields(gameId string, fields database.UserFields) *userRepositoryGetUserFromFieldsCall { + return _c.Parent.OnGetUserFromFields(gameId, fields) +} + +func (_c *userRepositoryCreateUserCall) OnGetUsers(filter database.GetUsersFilter) *userRepositoryGetUsersCall { + return _c.Parent.OnGetUsers(filter) +} + +func (_c *userRepositoryCreateUserCall) OnCreateUserRaw(user interface{}) *userRepositoryCreateUserCall { + return _c.Parent.OnCreateUserRaw(user) +} + +func (_c *userRepositoryCreateUserCall) OnGetUserRaw(userId interface{}) *userRepositoryGetUserCall { + return _c.Parent.OnGetUserRaw(userId) +} + +func (_c *userRepositoryCreateUserCall) OnGetUserFromFieldsRaw(gameId interface{}, fields interface{}) *userRepositoryGetUserFromFieldsCall { + return _c.Parent.OnGetUserFromFieldsRaw(gameId, fields) +} + +func (_c *userRepositoryCreateUserCall) OnGetUsersRaw(filter interface{}) *userRepositoryGetUsersCall { + return _c.Parent.OnGetUsersRaw(filter) +} + +func (_m *userRepositoryMock) GetUser(_ context.Context, userId string) (*database.User, error) { + _ret := _m.Called(userId) + + if _rf, ok := _ret.Get(0).(func(string) (*database.User, error)); ok { + return _rf(userId) + } + + _ra0, _ := _ret.Get(0).(*database.User) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *userRepositoryMock) OnGetUser(userId string) *userRepositoryGetUserCall { + return &userRepositoryGetUserCall{Call: _m.Mock.On("GetUser", userId), Parent: _m} +} + +func (_m *userRepositoryMock) OnGetUserRaw(userId interface{}) *userRepositoryGetUserCall { + return &userRepositoryGetUserCall{Call: _m.Mock.On("GetUser", userId), Parent: _m} +} + +type userRepositoryGetUserCall struct { + *mock.Call + Parent *userRepositoryMock +} + +func (_c *userRepositoryGetUserCall) Panic(msg string) *userRepositoryGetUserCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *userRepositoryGetUserCall) Once() *userRepositoryGetUserCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *userRepositoryGetUserCall) Twice() *userRepositoryGetUserCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *userRepositoryGetUserCall) Times(i int) *userRepositoryGetUserCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *userRepositoryGetUserCall) WaitUntil(w <-chan time.Time) *userRepositoryGetUserCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *userRepositoryGetUserCall) After(d time.Duration) *userRepositoryGetUserCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *userRepositoryGetUserCall) Run(fn func(args mock.Arguments)) *userRepositoryGetUserCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *userRepositoryGetUserCall) Maybe() *userRepositoryGetUserCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *userRepositoryGetUserCall) TypedReturns(a *database.User, b error) *userRepositoryGetUserCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *userRepositoryGetUserCall) ReturnsFn(fn func(string) (*database.User, error)) *userRepositoryGetUserCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *userRepositoryGetUserCall) TypedRun(fn func(string)) *userRepositoryGetUserCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _userId := args.String(0) + fn(_userId) + }) + return _c +} + +func (_c *userRepositoryGetUserCall) OnCreateUser(user database.CreateUser) *userRepositoryCreateUserCall { + return _c.Parent.OnCreateUser(user) +} + +func (_c *userRepositoryGetUserCall) OnGetUser(userId string) *userRepositoryGetUserCall { + return _c.Parent.OnGetUser(userId) +} + +func (_c *userRepositoryGetUserCall) OnGetUserFromFields(gameId string, fields database.UserFields) *userRepositoryGetUserFromFieldsCall { + return _c.Parent.OnGetUserFromFields(gameId, fields) +} + +func (_c *userRepositoryGetUserCall) OnGetUsers(filter database.GetUsersFilter) *userRepositoryGetUsersCall { + return _c.Parent.OnGetUsers(filter) +} + +func (_c *userRepositoryGetUserCall) OnCreateUserRaw(user interface{}) *userRepositoryCreateUserCall { + return _c.Parent.OnCreateUserRaw(user) +} + +func (_c *userRepositoryGetUserCall) OnGetUserRaw(userId interface{}) *userRepositoryGetUserCall { + return _c.Parent.OnGetUserRaw(userId) +} + +func (_c *userRepositoryGetUserCall) OnGetUserFromFieldsRaw(gameId interface{}, fields interface{}) *userRepositoryGetUserFromFieldsCall { + return _c.Parent.OnGetUserFromFieldsRaw(gameId, fields) +} + +func (_c *userRepositoryGetUserCall) OnGetUsersRaw(filter interface{}) *userRepositoryGetUsersCall { + return _c.Parent.OnGetUsersRaw(filter) +} + +func (_m *userRepositoryMock) GetUserFromFields(_ context.Context, gameId string, fields database.UserFields) (*database.User, error) { + _ret := _m.Called(gameId, fields) + + if _rf, ok := _ret.Get(0).(func(string, database.UserFields) (*database.User, error)); ok { + return _rf(gameId, fields) + } + + _ra0, _ := _ret.Get(0).(*database.User) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *userRepositoryMock) OnGetUserFromFields(gameId string, fields database.UserFields) *userRepositoryGetUserFromFieldsCall { + return &userRepositoryGetUserFromFieldsCall{Call: _m.Mock.On("GetUserFromFields", gameId, fields), Parent: _m} +} + +func (_m *userRepositoryMock) OnGetUserFromFieldsRaw(gameId interface{}, fields interface{}) *userRepositoryGetUserFromFieldsCall { + return &userRepositoryGetUserFromFieldsCall{Call: _m.Mock.On("GetUserFromFields", gameId, fields), Parent: _m} +} + +type userRepositoryGetUserFromFieldsCall struct { + *mock.Call + Parent *userRepositoryMock +} + +func (_c *userRepositoryGetUserFromFieldsCall) Panic(msg string) *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) Once() *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) Twice() *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) Times(i int) *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) WaitUntil(w <-chan time.Time) *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) After(d time.Duration) *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) Run(fn func(args mock.Arguments)) *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) Maybe() *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) TypedReturns(a *database.User, b error) *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) ReturnsFn(fn func(string, database.UserFields) (*database.User, error)) *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) TypedRun(fn func(string, database.UserFields)) *userRepositoryGetUserFromFieldsCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _gameId := args.String(0) + _fields, _ := args.Get(1).(database.UserFields) + fn(_gameId, _fields) + }) + return _c +} + +func (_c *userRepositoryGetUserFromFieldsCall) OnCreateUser(user database.CreateUser) *userRepositoryCreateUserCall { + return _c.Parent.OnCreateUser(user) +} + +func (_c *userRepositoryGetUserFromFieldsCall) OnGetUser(userId string) *userRepositoryGetUserCall { + return _c.Parent.OnGetUser(userId) +} + +func (_c *userRepositoryGetUserFromFieldsCall) OnGetUserFromFields(gameId string, fields database.UserFields) *userRepositoryGetUserFromFieldsCall { + return _c.Parent.OnGetUserFromFields(gameId, fields) +} + +func (_c *userRepositoryGetUserFromFieldsCall) OnGetUsers(filter database.GetUsersFilter) *userRepositoryGetUsersCall { + return _c.Parent.OnGetUsers(filter) +} + +func (_c *userRepositoryGetUserFromFieldsCall) OnCreateUserRaw(user interface{}) *userRepositoryCreateUserCall { + return _c.Parent.OnCreateUserRaw(user) +} + +func (_c *userRepositoryGetUserFromFieldsCall) OnGetUserRaw(userId interface{}) *userRepositoryGetUserCall { + return _c.Parent.OnGetUserRaw(userId) +} + +func (_c *userRepositoryGetUserFromFieldsCall) OnGetUserFromFieldsRaw(gameId interface{}, fields interface{}) *userRepositoryGetUserFromFieldsCall { + return _c.Parent.OnGetUserFromFieldsRaw(gameId, fields) +} + +func (_c *userRepositoryGetUserFromFieldsCall) OnGetUsersRaw(filter interface{}) *userRepositoryGetUsersCall { + return _c.Parent.OnGetUsersRaw(filter) +} + +func (_m *userRepositoryMock) GetUsers(_ context.Context, filter database.GetUsersFilter) ([]database.User, error) { + _ret := _m.Called(filter) + + if _rf, ok := _ret.Get(0).(func(database.GetUsersFilter) ([]database.User, error)); ok { + return _rf(filter) + } + + _ra0, _ := _ret.Get(0).([]database.User) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *userRepositoryMock) OnGetUsers(filter database.GetUsersFilter) *userRepositoryGetUsersCall { + return &userRepositoryGetUsersCall{Call: _m.Mock.On("GetUsers", filter), Parent: _m} +} + +func (_m *userRepositoryMock) OnGetUsersRaw(filter interface{}) *userRepositoryGetUsersCall { + return &userRepositoryGetUsersCall{Call: _m.Mock.On("GetUsers", filter), Parent: _m} +} + +type userRepositoryGetUsersCall struct { + *mock.Call + Parent *userRepositoryMock +} + +func (_c *userRepositoryGetUsersCall) Panic(msg string) *userRepositoryGetUsersCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *userRepositoryGetUsersCall) Once() *userRepositoryGetUsersCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *userRepositoryGetUsersCall) Twice() *userRepositoryGetUsersCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *userRepositoryGetUsersCall) Times(i int) *userRepositoryGetUsersCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *userRepositoryGetUsersCall) WaitUntil(w <-chan time.Time) *userRepositoryGetUsersCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *userRepositoryGetUsersCall) After(d time.Duration) *userRepositoryGetUsersCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *userRepositoryGetUsersCall) Run(fn func(args mock.Arguments)) *userRepositoryGetUsersCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *userRepositoryGetUsersCall) Maybe() *userRepositoryGetUsersCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *userRepositoryGetUsersCall) TypedReturns(a []database.User, b error) *userRepositoryGetUsersCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *userRepositoryGetUsersCall) ReturnsFn(fn func(database.GetUsersFilter) ([]database.User, error)) *userRepositoryGetUsersCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *userRepositoryGetUsersCall) TypedRun(fn func(database.GetUsersFilter)) *userRepositoryGetUsersCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _filter, _ := args.Get(0).(database.GetUsersFilter) + fn(_filter) + }) + return _c +} + +func (_c *userRepositoryGetUsersCall) OnCreateUser(user database.CreateUser) *userRepositoryCreateUserCall { + return _c.Parent.OnCreateUser(user) +} + +func (_c *userRepositoryGetUsersCall) OnGetUser(userId string) *userRepositoryGetUserCall { + return _c.Parent.OnGetUser(userId) +} + +func (_c *userRepositoryGetUsersCall) OnGetUserFromFields(gameId string, fields database.UserFields) *userRepositoryGetUserFromFieldsCall { + return _c.Parent.OnGetUserFromFields(gameId, fields) +} + +func (_c *userRepositoryGetUsersCall) OnGetUsers(filter database.GetUsersFilter) *userRepositoryGetUsersCall { + return _c.Parent.OnGetUsers(filter) +} + +func (_c *userRepositoryGetUsersCall) OnCreateUserRaw(user interface{}) *userRepositoryCreateUserCall { + return _c.Parent.OnCreateUserRaw(user) +} + +func (_c *userRepositoryGetUsersCall) OnGetUserRaw(userId interface{}) *userRepositoryGetUserCall { + return _c.Parent.OnGetUserRaw(userId) +} + +func (_c *userRepositoryGetUsersCall) OnGetUserFromFieldsRaw(gameId interface{}, fields interface{}) *userRepositoryGetUserFromFieldsCall { + return _c.Parent.OnGetUserFromFieldsRaw(gameId, fields) +} + +func (_c *userRepositoryGetUsersCall) OnGetUsersRaw(filter interface{}) *userRepositoryGetUsersCall { + return _c.Parent.OnGetUsersRaw(filter) +} + +// wonPrizeRepositoryMock mock of WonPrizeRepository. +type wonPrizeRepositoryMock struct{ mock.Mock } + +// NewWonPrizeRepositoryMock creates a new wonPrizeRepositoryMock. +func NewWonPrizeRepositoryMock(tb testing.TB) *wonPrizeRepositoryMock { + tb.Helper() + + m := &wonPrizeRepositoryMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *wonPrizeRepositoryMock) CreateWonPrize(_ context.Context, wonPrize database.CreateWonPrize) error { + _ret := _m.Called(wonPrize) + + if _rf, ok := _ret.Get(0).(func(database.CreateWonPrize) error); ok { + return _rf(wonPrize) + } + + _ra0 := _ret.Error(0) + + return _ra0 +} + +func (_m *wonPrizeRepositoryMock) OnCreateWonPrize(wonPrize database.CreateWonPrize) *wonPrizeRepositoryCreateWonPrizeCall { + return &wonPrizeRepositoryCreateWonPrizeCall{Call: _m.Mock.On("CreateWonPrize", wonPrize), Parent: _m} +} + +func (_m *wonPrizeRepositoryMock) OnCreateWonPrizeRaw(wonPrize interface{}) *wonPrizeRepositoryCreateWonPrizeCall { + return &wonPrizeRepositoryCreateWonPrizeCall{Call: _m.Mock.On("CreateWonPrize", wonPrize), Parent: _m} +} + +type wonPrizeRepositoryCreateWonPrizeCall struct { + *mock.Call + Parent *wonPrizeRepositoryMock +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) Panic(msg string) *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) Once() *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) Twice() *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) Times(i int) *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) WaitUntil(w <-chan time.Time) *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) After(d time.Duration) *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) Run(fn func(args mock.Arguments)) *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) Maybe() *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) TypedReturns(a error) *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Return(a) + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) ReturnsFn(fn func(database.CreateWonPrize) error) *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) TypedRun(fn func(database.CreateWonPrize)) *wonPrizeRepositoryCreateWonPrizeCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _wonPrize, _ := args.Get(0).(database.CreateWonPrize) + fn(_wonPrize) + }) + return _c +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) OnCreateWonPrize(wonPrize database.CreateWonPrize) *wonPrizeRepositoryCreateWonPrizeCall { + return _c.Parent.OnCreateWonPrize(wonPrize) +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) OnGetWonPrizes(filter database.GetWonPrizesFilter) *wonPrizeRepositoryGetWonPrizesCall { + return _c.Parent.OnGetWonPrizes(filter) +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) OnCreateWonPrizeRaw(wonPrize interface{}) *wonPrizeRepositoryCreateWonPrizeCall { + return _c.Parent.OnCreateWonPrizeRaw(wonPrize) +} + +func (_c *wonPrizeRepositoryCreateWonPrizeCall) OnGetWonPrizesRaw(filter interface{}) *wonPrizeRepositoryGetWonPrizesCall { + return _c.Parent.OnGetWonPrizesRaw(filter) +} + +func (_m *wonPrizeRepositoryMock) GetWonPrizes(_ context.Context, filter database.GetWonPrizesFilter) ([]database.WonPrize, error) { + _ret := _m.Called(filter) + + if _rf, ok := _ret.Get(0).(func(database.GetWonPrizesFilter) ([]database.WonPrize, error)); ok { + return _rf(filter) + } + + _ra0, _ := _ret.Get(0).([]database.WonPrize) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *wonPrizeRepositoryMock) OnGetWonPrizes(filter database.GetWonPrizesFilter) *wonPrizeRepositoryGetWonPrizesCall { + return &wonPrizeRepositoryGetWonPrizesCall{Call: _m.Mock.On("GetWonPrizes", filter), Parent: _m} +} + +func (_m *wonPrizeRepositoryMock) OnGetWonPrizesRaw(filter interface{}) *wonPrizeRepositoryGetWonPrizesCall { + return &wonPrizeRepositoryGetWonPrizesCall{Call: _m.Mock.On("GetWonPrizes", filter), Parent: _m} +} + +type wonPrizeRepositoryGetWonPrizesCall struct { + *mock.Call + Parent *wonPrizeRepositoryMock +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) Panic(msg string) *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) Once() *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) Twice() *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) Times(i int) *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) WaitUntil(w <-chan time.Time) *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) After(d time.Duration) *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) Run(fn func(args mock.Arguments)) *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) Maybe() *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) TypedReturns(a []database.WonPrize, b error) *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) ReturnsFn(fn func(database.GetWonPrizesFilter) ([]database.WonPrize, error)) *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) TypedRun(fn func(database.GetWonPrizesFilter)) *wonPrizeRepositoryGetWonPrizesCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _filter, _ := args.Get(0).(database.GetWonPrizesFilter) + fn(_filter) + }) + return _c +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) OnCreateWonPrize(wonPrize database.CreateWonPrize) *wonPrizeRepositoryCreateWonPrizeCall { + return _c.Parent.OnCreateWonPrize(wonPrize) +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) OnGetWonPrizes(filter database.GetWonPrizesFilter) *wonPrizeRepositoryGetWonPrizesCall { + return _c.Parent.OnGetWonPrizes(filter) +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) OnCreateWonPrizeRaw(wonPrize interface{}) *wonPrizeRepositoryCreateWonPrizeCall { + return _c.Parent.OnCreateWonPrizeRaw(wonPrize) +} + +func (_c *wonPrizeRepositoryGetWonPrizesCall) OnGetWonPrizesRaw(filter interface{}) *wonPrizeRepositoryGetWonPrizesCall { + return _c.Parent.OnGetWonPrizesRaw(filter) +} diff --git a/internal/database/mock_test.go b/internal/database/mock_test.go new file mode 100644 index 0000000..2e419fe --- /dev/null +++ b/internal/database/mock_test.go @@ -0,0 +1,10 @@ +package database + +// mocktail:DrawMethodRepository +// mocktail:GameRepository +// mocktail:MailTemplateRepository +// mocktail:ParticipationRepository +// mocktail:ParticipationMethodRepository +// mocktail:PrizeRepository +// mocktail:UserRepository +// mocktail:WonPrizeRepository diff --git a/internal/pkg/clients/addressvalidation/client.go b/internal/pkg/clients/addressvalidation/client.go index 786bfe9..091a6f3 100644 --- a/internal/pkg/clients/addressvalidation/client.go +++ b/internal/pkg/clients/addressvalidation/client.go @@ -8,21 +8,25 @@ import ( "google.golang.org/genproto/googleapis/type/postaladdress" ) -type Client struct { +type Client interface { + NormalizeAddress(ctx context.Context, address string) (string, error) +} + +type client struct { client *addressvalidation.Client } -func NewClient(ctx context.Context, apiKey string) (*Client, error) { - client, err := addressvalidation.NewClient(ctx, option.WithAPIKey(apiKey)) +func NewClient(ctx context.Context, apiKey string) (Client, error) { + c, err := addressvalidation.NewClient(ctx, option.WithAPIKey(apiKey)) if err != nil { return nil, err } - return &Client{ - client: client, + return &client{ + client: c, }, nil } -func (c *Client) NormalizeAddress(ctx context.Context, address string) (string, error) { +func (c *client) NormalizeAddress(ctx context.Context, address string) (string, error) { request := &addressvalidationpb.ValidateAddressRequest{ Address: &postaladdress.PostalAddress{ AddressLines: []string{address}, diff --git a/internal/pkg/clients/addressvalidation/mock_gen.go b/internal/pkg/clients/addressvalidation/mock_gen.go new file mode 100644 index 0000000..d6db7b5 --- /dev/null +++ b/internal/pkg/clients/addressvalidation/mock_gen.go @@ -0,0 +1,118 @@ +// Code generated by mocktail; DO NOT EDIT. + +package addressvalidation + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/mock" +) + +// clientMock mock of Client. +type clientMock struct{ mock.Mock } + +// NewClientMock creates a new clientMock. +func NewClientMock(tb testing.TB) *clientMock { + tb.Helper() + + m := &clientMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *clientMock) NormalizeAddress(_ context.Context, address string) (string, error) { + _ret := _m.Called(address) + + if _rf, ok := _ret.Get(0).(func(string) (string, error)); ok { + return _rf(address) + } + + _ra0 := _ret.String(0) + _rb1 := _ret.Error(1) + + return _ra0, _rb1 +} + +func (_m *clientMock) OnNormalizeAddress(address string) *clientNormalizeAddressCall { + return &clientNormalizeAddressCall{Call: _m.Mock.On("NormalizeAddress", address), Parent: _m} +} + +func (_m *clientMock) OnNormalizeAddressRaw(address interface{}) *clientNormalizeAddressCall { + return &clientNormalizeAddressCall{Call: _m.Mock.On("NormalizeAddress", address), Parent: _m} +} + +type clientNormalizeAddressCall struct { + *mock.Call + Parent *clientMock +} + +func (_c *clientNormalizeAddressCall) Panic(msg string) *clientNormalizeAddressCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *clientNormalizeAddressCall) Once() *clientNormalizeAddressCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *clientNormalizeAddressCall) Twice() *clientNormalizeAddressCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *clientNormalizeAddressCall) Times(i int) *clientNormalizeAddressCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *clientNormalizeAddressCall) WaitUntil(w <-chan time.Time) *clientNormalizeAddressCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *clientNormalizeAddressCall) After(d time.Duration) *clientNormalizeAddressCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *clientNormalizeAddressCall) Run(fn func(args mock.Arguments)) *clientNormalizeAddressCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *clientNormalizeAddressCall) Maybe() *clientNormalizeAddressCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *clientNormalizeAddressCall) TypedReturns(a string, b error) *clientNormalizeAddressCall { + _c.Call = _c.Return(a, b) + return _c +} + +func (_c *clientNormalizeAddressCall) ReturnsFn(fn func(string) (string, error)) *clientNormalizeAddressCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *clientNormalizeAddressCall) TypedRun(fn func(string)) *clientNormalizeAddressCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _address := args.String(0) + fn(_address) + }) + return _c +} + +func (_c *clientNormalizeAddressCall) OnNormalizeAddress(address string) *clientNormalizeAddressCall { + return _c.Parent.OnNormalizeAddress(address) +} + +func (_c *clientNormalizeAddressCall) OnNormalizeAddressRaw(address interface{}) *clientNormalizeAddressCall { + return _c.Parent.OnNormalizeAddressRaw(address) +} diff --git a/internal/pkg/clients/addressvalidation/mock_test.go b/internal/pkg/clients/addressvalidation/mock_test.go new file mode 100644 index 0000000..6ddcd2d --- /dev/null +++ b/internal/pkg/clients/addressvalidation/mock_test.go @@ -0,0 +1,3 @@ +package addressvalidation + +// mocktail:Client diff --git a/internal/pkg/clients/mandrill/client.go b/internal/pkg/clients/mandrill/client.go new file mode 100644 index 0000000..db8109f --- /dev/null +++ b/internal/pkg/clients/mandrill/client.go @@ -0,0 +1,33 @@ +package mandrill + +import ( + "github.com/mattbaird/gochimp" +) + +type Client interface { + SendTemplate(templateName string, message gochimp.Message) error +} + +type client struct { + client *gochimp.MandrillAPI +} + +func NewClient(apiKey string) (Client, error) { + c, err := gochimp.NewMandrill(apiKey) + if err != nil { + return nil, err + } + return &client{ + client: c, + }, nil +} + +func (c *client) SendTemplate(templateName string, message gochimp.Message) error { + _, err := c.client.MessageSendTemplate( + templateName, + []gochimp.Var{}, + message, + true, + ) + return err +} diff --git a/internal/pkg/clients/mandrill/mock_gen.go b/internal/pkg/clients/mandrill/mock_gen.go new file mode 100644 index 0000000..ab01586 --- /dev/null +++ b/internal/pkg/clients/mandrill/mock_gen.go @@ -0,0 +1,118 @@ +// Code generated by mocktail; DO NOT EDIT. + +package mandrill + +import ( + "testing" + "time" + + "github.com/mattbaird/gochimp" + "github.com/stretchr/testify/mock" +) + +// clientMock mock of Client. +type clientMock struct{ mock.Mock } + +// NewClientMock creates a new clientMock. +func NewClientMock(tb testing.TB) *clientMock { + tb.Helper() + + m := &clientMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *clientMock) SendTemplate(templateName string, message gochimp.Message) error { + _ret := _m.Called(templateName, message) + + if _rf, ok := _ret.Get(0).(func(string, gochimp.Message) error); ok { + return _rf(templateName, message) + } + + _ra0 := _ret.Error(0) + + return _ra0 +} + +func (_m *clientMock) OnSendTemplate(templateName string, message gochimp.Message) *clientSendTemplateCall { + return &clientSendTemplateCall{Call: _m.Mock.On("SendTemplate", templateName, message), Parent: _m} +} + +func (_m *clientMock) OnSendTemplateRaw(templateName interface{}, message interface{}) *clientSendTemplateCall { + return &clientSendTemplateCall{Call: _m.Mock.On("SendTemplate", templateName, message), Parent: _m} +} + +type clientSendTemplateCall struct { + *mock.Call + Parent *clientMock +} + +func (_c *clientSendTemplateCall) Panic(msg string) *clientSendTemplateCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *clientSendTemplateCall) Once() *clientSendTemplateCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *clientSendTemplateCall) Twice() *clientSendTemplateCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *clientSendTemplateCall) Times(i int) *clientSendTemplateCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *clientSendTemplateCall) WaitUntil(w <-chan time.Time) *clientSendTemplateCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *clientSendTemplateCall) After(d time.Duration) *clientSendTemplateCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *clientSendTemplateCall) Run(fn func(args mock.Arguments)) *clientSendTemplateCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *clientSendTemplateCall) Maybe() *clientSendTemplateCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *clientSendTemplateCall) TypedReturns(a error) *clientSendTemplateCall { + _c.Call = _c.Return(a) + return _c +} + +func (_c *clientSendTemplateCall) ReturnsFn(fn func(string, gochimp.Message) error) *clientSendTemplateCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *clientSendTemplateCall) TypedRun(fn func(string, gochimp.Message)) *clientSendTemplateCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _templateName := args.String(0) + _message, _ := args.Get(1).(gochimp.Message) + fn(_templateName, _message) + }) + return _c +} + +func (_c *clientSendTemplateCall) OnSendTemplate(templateName string, message gochimp.Message) *clientSendTemplateCall { + return _c.Parent.OnSendTemplate(templateName, message) +} + +func (_c *clientSendTemplateCall) OnSendTemplateRaw(templateName interface{}, message interface{}) *clientSendTemplateCall { + return _c.Parent.OnSendTemplateRaw(templateName, message) +} diff --git a/internal/pkg/clients/mandrill/mock_test.go b/internal/pkg/clients/mandrill/mock_test.go new file mode 100644 index 0000000..b57e961 --- /dev/null +++ b/internal/pkg/clients/mandrill/mock_test.go @@ -0,0 +1,3 @@ +package mandrill + +// mocktail:Client diff --git a/internal/pkg/clients/sheets/client.go b/internal/pkg/clients/sheets/client.go index d4b2026..b06f5f6 100644 --- a/internal/pkg/clients/sheets/client.go +++ b/internal/pkg/clients/sheets/client.go @@ -6,21 +6,25 @@ import ( "google.golang.org/api/sheets/v4" ) -type Client struct { +type Client interface { + AppendRow(sheetId string, tabName string, values []any) error +} + +type client struct { client *sheets.Service } -func NewClient(ctx context.Context, serviceAccountKeyPath string) (*Client, error) { +func NewClient(ctx context.Context, serviceAccountKeyPath string) (Client, error) { service, err := sheets.NewService(ctx, option.WithCredentialsFile(serviceAccountKeyPath)) if err != nil { return nil, err } - return &Client{ + return &client{ client: service, }, nil } -func (c *Client) AppendRow(sheetId string, tabName string, values []any) error { +func (c *client) AppendRow(sheetId string, tabName string, values []any) error { _, err := c.client.Spreadsheets.Values. Append(sheetId, tabName, &sheets.ValueRange{ MajorDimension: "ROWS", diff --git a/internal/pkg/clients/sheets/mock_gen.go b/internal/pkg/clients/sheets/mock_gen.go new file mode 100644 index 0000000..77681cd --- /dev/null +++ b/internal/pkg/clients/sheets/mock_gen.go @@ -0,0 +1,118 @@ +// Code generated by mocktail; DO NOT EDIT. + +package sheets + +import ( + "testing" + "time" + + "github.com/stretchr/testify/mock" +) + +// clientMock mock of Client. +type clientMock struct{ mock.Mock } + +// NewClientMock creates a new clientMock. +func NewClientMock(tb testing.TB) *clientMock { + tb.Helper() + + m := &clientMock{} + m.Mock.Test(tb) + + tb.Cleanup(func() { m.AssertExpectations(tb) }) + + return m +} + +func (_m *clientMock) AppendRow(sheetId string, tabName string, values []any) error { + _ret := _m.Called(sheetId, tabName, values) + + if _rf, ok := _ret.Get(0).(func(string, string, []any) error); ok { + return _rf(sheetId, tabName, values) + } + + _ra0 := _ret.Error(0) + + return _ra0 +} + +func (_m *clientMock) OnAppendRow(sheetId string, tabName string, values []any) *clientAppendRowCall { + return &clientAppendRowCall{Call: _m.Mock.On("AppendRow", sheetId, tabName, values), Parent: _m} +} + +func (_m *clientMock) OnAppendRowRaw(sheetId interface{}, tabName interface{}, values interface{}) *clientAppendRowCall { + return &clientAppendRowCall{Call: _m.Mock.On("AppendRow", sheetId, tabName, values), Parent: _m} +} + +type clientAppendRowCall struct { + *mock.Call + Parent *clientMock +} + +func (_c *clientAppendRowCall) Panic(msg string) *clientAppendRowCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *clientAppendRowCall) Once() *clientAppendRowCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *clientAppendRowCall) Twice() *clientAppendRowCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *clientAppendRowCall) Times(i int) *clientAppendRowCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *clientAppendRowCall) WaitUntil(w <-chan time.Time) *clientAppendRowCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *clientAppendRowCall) After(d time.Duration) *clientAppendRowCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *clientAppendRowCall) Run(fn func(args mock.Arguments)) *clientAppendRowCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *clientAppendRowCall) Maybe() *clientAppendRowCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *clientAppendRowCall) TypedReturns(a error) *clientAppendRowCall { + _c.Call = _c.Return(a) + return _c +} + +func (_c *clientAppendRowCall) ReturnsFn(fn func(string, string, []any) error) *clientAppendRowCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *clientAppendRowCall) TypedRun(fn func(string, string, []any)) *clientAppendRowCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _sheetId := args.String(0) + _tabName := args.String(1) + _values, _ := args.Get(2).([]any) + fn(_sheetId, _tabName, _values) + }) + return _c +} + +func (_c *clientAppendRowCall) OnAppendRow(sheetId string, tabName string, values []any) *clientAppendRowCall { + return _c.Parent.OnAppendRow(sheetId, tabName, values) +} + +func (_c *clientAppendRowCall) OnAppendRowRaw(sheetId interface{}, tabName interface{}, values interface{}) *clientAppendRowCall { + return _c.Parent.OnAppendRowRaw(sheetId, tabName, values) +} diff --git a/internal/pkg/clients/sheets/mock_test.go b/internal/pkg/clients/sheets/mock_test.go new file mode 100644 index 0000000..93d27bb --- /dev/null +++ b/internal/pkg/clients/sheets/mock_test.go @@ -0,0 +1,3 @@ +package sheets + +// mocktail:Client diff --git a/internal/service/game.go b/internal/service/game.go index a6c88f8..b8b56d6 100644 --- a/internal/service/game.go +++ b/internal/service/game.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/gapidobri/prizer/internal/database" "github.com/gapidobri/prizer/internal/pkg/clients/addressvalidation" + "github.com/gapidobri/prizer/internal/pkg/clients/mandrill" "github.com/gapidobri/prizer/internal/pkg/clients/sheets" er "github.com/gapidobri/prizer/internal/pkg/errors" "github.com/gapidobri/prizer/internal/pkg/models/api" @@ -32,9 +33,9 @@ type GameService struct { participationMethodRepository database.ParticipationMethodRepository participationRepository database.ParticipationRepository mailTemplateRepository database.MailTemplateRepository - addressValidationClient *addressvalidation.Client - mandrillClient *gochimp.MandrillAPI - sheetsClient *sheets.Client + addressValidationClient addressvalidation.Client + mandrillClient mandrill.Client + sheetsClient sheets.Client } func NewGameService( @@ -46,9 +47,9 @@ func NewGameService( participationMethodRepository database.ParticipationMethodRepository, participationRepository database.ParticipationRepository, mailTemplateRepository database.MailTemplateRepository, - addressValidationClient *addressvalidation.Client, - mandrillClient *gochimp.MandrillAPI, - sheetsClient *sheets.Client, + addressValidationClient addressvalidation.Client, + mandrillClient mandrill.Client, + sheetsClient sheets.Client, ) *GameService { return &GameService{ gameRepository: gameRepository, @@ -357,9 +358,8 @@ func (s *GameService) Participate(ctx context.Context, participationMethodId str }) } - _, err = s.mandrillClient.MessageSendTemplate( + err = s.mandrillClient.SendTemplate( template.Name, - []gochimp.Var{}, gochimp.Message{ FromEmail: template.FromEmail, FromName: template.FromName, @@ -369,7 +369,6 @@ func (s *GameService) Participate(ctx context.Context, participationMethodId str {Email: *user.Email}, }, }, - true, ) if err != nil { log.WithError(err).Error("Failed to send win email") @@ -401,9 +400,8 @@ func (s *GameService) Participate(ctx context.Context, participationMethodId str }) } - _, err = s.mandrillClient.MessageSendTemplate( + err = s.mandrillClient.SendTemplate( template.Name, - []gochimp.Var{}, gochimp.Message{ FromEmail: template.FromEmail, FromName: template.FromName, @@ -413,7 +411,6 @@ func (s *GameService) Participate(ctx context.Context, participationMethodId str {Email: *user.Email}, }, }, - true, ) if err != nil { log.WithError(err).Error("Failed to send lose email") diff --git a/internal/service/game_test.go b/internal/service/game_test.go new file mode 100644 index 0000000..6b4026a --- /dev/null +++ b/internal/service/game_test.go @@ -0,0 +1,161 @@ +package service + +import ( + "context" + "github.com/gapidobri/prizer/internal/database" + "github.com/gapidobri/prizer/internal/pkg/clients/addressvalidation" + "github.com/gapidobri/prizer/internal/pkg/clients/mandrill" + "github.com/gapidobri/prizer/internal/pkg/clients/sheets" + "github.com/gapidobri/prizer/internal/pkg/models/api" + dbModels "github.com/gapidobri/prizer/internal/pkg/models/database" + "github.com/gapidobri/prizer/internal/pkg/models/enums" + "github.com/samber/lo" + "github.com/stretchr/testify/require" + "testing" +) + +var ( + game = dbModels.Game{ + Id: "049fce3d-46d6-4dbf-ad70-3b93e98e6d58", + } + participationMethod = dbModels.ParticipationMethod{ + Id: "3ef7669-0179-4347-895a-cb8b045f74f8", + GameId: game.Id, + Limit: enums.ParticipationLimitNone, + Fields: dbModels.FieldConfig{ + User: map[string]dbModels.Field{ + "name": { + Type: enums.FieldTypeString, + Required: true, + Unique: false, + }, + "email": { + Type: enums.FieldTypeString, + Required: true, + Unique: true, + }, + }, + Participation: map[string]dbModels.Field{ + "code": { + Type: enums.FieldTypeString, + Required: true, + Unique: true, + }, + }, + }, + } + drawMethodChanceAlways = dbModels.DrawMethod{ + Id: "4af50df6-67a4-4771-80f3-a5267f9af684", + Method: dbModels.DrawMethodChance, + Data: "{\"chance\": \"1\"}", + } + drawMethodChanceNever = dbModels.DrawMethod{ + Id: "0a4079bd-6fbe-4e08-ae97-7ba993b81a30", + Method: dbModels.DrawMethodChance, + Data: "{\"chance\": \"0\"}", + } + drawMethodFirstN = dbModels.DrawMethod{ + Id: "e8840492-7ece-4d90-a0b2-02ebea5752b3", + Method: dbModels.DrawMethodFirstN, + Data: "{}", + } + user = dbModels.User{ + Id: "564a1991-caff-44fd-98f2-12e64c30aa8c", + GameId: game.Id, + UserFields: dbModels.UserFields{ + Email: lo.ToPtr("test@example.com"), + }, + AdditionalFields: map[string]any{ + "name": "Test User", + }, + } + prize = dbModels.Prize{ + Id: "560b6b8b-2ea0-4bf8-b38c-425ff3175217", + GameId: game.Id, + Name: "Prize Name", + Description: "Prize Description", + Count: 1, + } + participation = dbModels.Participation{ + Id: "3638e1e5-894d-4df5-947e-61e04e046d6e", + UserId: user.Id, + ParticipationMethodId: participationMethod.Id, + } +) + +func TestGameService_Participate(t *testing.T) { + ctx := context.Background() + + gameRepo := database.NewGameRepositoryMock(t) + prizeRepo := database.NewPrizeRepositoryMock(t) + wonPrizeRepo := database.NewWonPrizeRepositoryMock(t) + userRepo := database.NewUserRepositoryMock(t) + drawMethodRepo := database.NewDrawMethodRepositoryMock(t) + participationMethodRepo := database.NewParticipationMethodRepositoryMock(t) + participationRepo := database.NewParticipationRepositoryMock(t) + mailTemplateRepo := database.NewMailTemplateRepositoryMock(t) + addressValidationClient := addressvalidation.NewClientMock(t) + mandrillClient := mandrill.NewClientMock(t) + sheetsClient := sheets.NewClientMock(t) + + gameService := NewGameService(gameRepo, prizeRepo, wonPrizeRepo, userRepo, drawMethodRepo, participationMethodRepo, + participationRepo, mailTemplateRepo, addressValidationClient, mandrillClient, sheetsClient) + + // Function mocks + + participationMethodRepo.OnGetParticipationMethod(participationMethod.Id).TypedReturns(&participationMethod, nil) + + gameRepo.OnGetGame(game.Id).TypedReturns(&game, nil) + + userRepo.OnGetUserFromFields(game.Id, user.UserFields).TypedReturns(&user, nil) + + participationRepo.OnGetParticipations(dbModels.GetParticipationsFilter{ + UserId: &user.Id, + ParticipationMethodId: &participationMethod.Id, + Fields: &dbModels.JsonMap{ + "code": "12345", + }, + }).TypedReturns([]dbModels.Participation{}, nil) + + drawMethodRepo.OnGetDrawMethods(game.Id, dbModels.GetDrawMethodsFilter{ + ParticipationMethodId: &participationMethod.Id, + }).TypedReturns([]dbModels.DrawMethod{drawMethodFirstN}, nil) + + prizeRepo.OnGetPrizes(dbModels.GetPrizesFilter{ + GameId: &game.Id, + DrawMethodId: &drawMethodFirstN.Id, + AvailableOnly: true, + }).TypedReturns([]dbModels.Prize{prize}, nil) + + participationRepo.OnCreateParticipation(dbModels.CreateParticipation{ + UserId: user.Id, + ParticipationMethodId: participationMethod.Id, + Fields: dbModels.JsonMap{ + "code": "12345", + }, + }).TypedReturns(&participation, nil) + + wonPrizeRepo.OnCreateWonPrize(dbModels.CreateWonPrize{ + PrizeId: prize.Id, + ParticipationId: participation.Id, + }).TypedReturns(nil) + + // Test + + request := api.ParticipationRequest{ + Fields: map[string]any{ + "email": "test@example.com", + "name": "Test User", + "code": "12345", + }, + } + + response, err := gameService.Participate(ctx, participationMethod.Id, request) + if err != nil { + t.Error(err) + } + + require.Equal(t, response, &api.ParticipationResponse{ + Prizes: []api.PublicPrize{api.PublicPrizeFromDB(prize)}, + }) +} diff --git a/makefile b/makefile index df581dc..6d6218a 100644 --- a/makefile +++ b/makefile @@ -3,4 +3,7 @@ update-db: generate-spec: SWAGGER_GENERATE_EXTENSION=false swagger generate spec --exclude-tag=admin --exclude=admin -m --exclude-deps -o ./api/public.yaml - SWAGGER_GENERATE_EXTENSION=false swagger generate spec --include-tag=admin --exclude=public -m --exclude-deps -o ./api/admin.yaml \ No newline at end of file + SWAGGER_GENERATE_EXTENSION=false swagger generate spec --include-tag=admin --exclude=public -m --exclude-deps -o ./api/admin.yaml + +generate-mocks: + mocktail -e \ No newline at end of file