Skip to content

Commit

Permalink
refactor: Removing interface along the way
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Aug 8, 2021
1 parent 987e45d commit fa5373b
Show file tree
Hide file tree
Showing 9 changed files with 367 additions and 134 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ scripts/
# Golang
bin/
release/
mocks/
coverage.*
profile.out

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ mocks:
mockgen -destination pkg/mocks/user_service.go -mock_names UserService=UserService -package mocks github.com/ViBiOh/ketchup/pkg/middleware UserService
mockgen -destination pkg/mocks/mailer.go -mock_names Mailer=Mailer -package mocks github.com/ViBiOh/ketchup/pkg/notifier Mailer
mockgen -destination pkg/mocks/auth.go -mock_names AuthService=Auth -package mocks github.com/ViBiOh/ketchup/pkg/service/user AuthService
mockgen -destination pkg/mocks/user_store.go -mock_names Store=UserStore -package mocks github.com/ViBiOh/ketchup/pkg/service/user Store

## test: Shortcut to launch all the test tasks (unit, functional and integration).
.PHONY: test
Expand Down
65 changes: 65 additions & 0 deletions pkg/mocks/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions pkg/mocks/mailer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions pkg/mocks/user_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions pkg/mocks/user_store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions pkg/service/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@ import (
"github.com/ViBiOh/httputils/v4/pkg/logger"
httpModel "github.com/ViBiOh/httputils/v4/pkg/model"
"github.com/ViBiOh/ketchup/pkg/model"
"github.com/ViBiOh/ketchup/pkg/store/user"
)

// AuthService defines interaction with storage and provider from User
// AuthService defines interaction with underlying User
type AuthService interface {
Create(context.Context, authModel.User) (authModel.User, error)
Check(context.Context, authModel.User, authModel.User) error
}

// Store defines interaction with User storage
type Store interface {
DoAtomic(context.Context, func(context.Context) error) error
GetByLoginID(context.Context, uint64) (model.User, error)
GetByEmail(context.Context, string) (model.User, error)
Create(context.Context, model.User) (uint64, error)
Count(context.Context) (uint64, error)
}

// App of package
type App struct {
userStore user.App
userStore Store
authApp AuthService
}

// New creates new App from Config
func New(userStore user.App, authApp AuthService) App {
func New(userStore Store, authApp AuthService) App {
return App{
userStore: userStore,
authApp: authApp,
Expand Down
Loading

0 comments on commit fa5373b

Please sign in to comment.