Skip to content

Commit

Permalink
Generate missing mocks [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 4, 2023
1 parent 08492b9 commit d8c3fcb
Show file tree
Hide file tree
Showing 6 changed files with 689 additions and 33 deletions.
98 changes: 98 additions & 0 deletions app/application/middleware/auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package middleware

import (
"reflect"
"testing"

"example.com/application/service"
"github.com/uptrace/bunrouter"
)

func TestNewMiddleware(t *testing.T) {
type args struct {
userService service.UserServiceInterface
}
tests := []struct {
name string
args args
want *Middleware
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewMiddleware(tt.args.userService); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewMiddleware() = %v, want %v", got, tt.want)
}
})
}
}

func TestMiddleware_AuthenticateMiddleware(t *testing.T) {
type fields struct {
UserService service.UserServiceInterface
}
tests := []struct {
name string
fields fields
want func(bunrouter.HandlerFunc) bunrouter.HandlerFunc
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := &Middleware{
UserService: tt.fields.UserService,
}
if got := m.AuthenticateMiddleware(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Middleware.AuthenticateMiddleware() = %v, want %v", got, tt.want)
}
})
}
}

func TestMiddleware_CorsMiddleware(t *testing.T) {
type fields struct {
UserService service.UserServiceInterface
}
tests := []struct {
name string
fields fields
want func(bunrouter.HandlerFunc) bunrouter.HandlerFunc
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := &Middleware{
UserService: tt.fields.UserService,
}
if got := m.CorsMiddleware(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Middleware.CorsMiddleware() = %v, want %v", got, tt.want)
}
})
}
}

func TestMiddleware_RecoverMiddleware(t *testing.T) {
type fields struct {
UserService service.UserServiceInterface
}
tests := []struct {
name string
fields fields
want func(bunrouter.HandlerFunc) bunrouter.HandlerFunc
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := &Middleware{
UserService: tt.fields.UserService,
}
if got := m.RecoverMiddleware(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Middleware.RecoverMiddleware() = %v, want %v", got, tt.want)
}
})
}
}
227 changes: 227 additions & 0 deletions app/application/service/user_service_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
package service

import (
"context"
"reflect"
"testing"

"example.com/domain"
"example.com/domain/repository"
)

func TestNewUserService(t *testing.T) {
type args struct {
UserRepository repository.UserRepository
}
tests := []struct {
name string
args args
want *UserService
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewUserService(tt.args.UserRepository); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewUserService() = %v, want %v", got, tt.want)
}
})
}
}

func TestUserService_Add(t *testing.T) {
type fields struct {
UserRepository repository.UserRepository
}
type args struct {
ctx context.Context
name string
}
tests := []struct {
name string
fields fields
args args
want string
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u := &UserService{
UserRepository: tt.fields.UserRepository,
}
got, err := u.Add(tt.args.ctx, tt.args.name)
if (err != nil) != tt.wantErr {
t.Errorf("UserService.Add() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("UserService.Add() = %v, want %v", got, tt.want)
}
})
}
}

func TestUserService_UpdateUser(t *testing.T) {
type fields struct {
UserRepository repository.UserRepository
}
type args struct {
ctx context.Context
user domain.User
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u := &UserService{
UserRepository: tt.fields.UserRepository,
}
if err := u.UpdateUser(tt.args.ctx, tt.args.user); (err != nil) != tt.wantErr {
t.Errorf("UserService.UpdateUser() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

func TestUserService_Delete(t *testing.T) {
type fields struct {
UserRepository repository.UserRepository
}
type args struct {
ctx context.Context
id string
}
tests := []struct {
name string
fields fields
args args
want string
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u := &UserService{
UserRepository: tt.fields.UserRepository,
}
got, err := u.Delete(tt.args.ctx, tt.args.id)
if (err != nil) != tt.wantErr {
t.Errorf("UserService.Delete() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("UserService.Delete() = %v, want %v", got, tt.want)
}
})
}
}

func TestUserService_GetUserByUserId(t *testing.T) {
type fields struct {
UserRepository repository.UserRepository
}
type args struct {
ctx context.Context
id string
}
tests := []struct {
name string
fields fields
args args
want domain.User
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u := &UserService{
UserRepository: tt.fields.UserRepository,
}
got, err := u.GetUserByUserId(tt.args.ctx, tt.args.id)
if (err != nil) != tt.wantErr {
t.Errorf("UserService.GetUserByUserId() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("UserService.GetUserByUserId() = %v, want %v", got, tt.want)
}
})
}
}

func TestUserService_GetUserByAuthToken(t *testing.T) {
type fields struct {
UserRepository repository.UserRepository
}
type args struct {
ctx context.Context
authToken string
}
tests := []struct {
name string
fields fields
args args
want *domain.User
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u := &UserService{
UserRepository: tt.fields.UserRepository,
}
got, err := u.GetUserByAuthToken(tt.args.ctx, tt.args.authToken)
if (err != nil) != tt.wantErr {
t.Errorf("UserService.GetUserByAuthToken() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("UserService.GetUserByAuthToken() = %v, want %v", got, tt.want)
}
})
}
}

func TestUserService_GetUserRanking(t *testing.T) {
type fields struct {
UserRepository repository.UserRepository
}
type args struct {
ctx context.Context
}
tests := []struct {
name string
fields fields
args args
want []*domain.UserRanking
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u := &UserService{
UserRepository: tt.fields.UserRepository,
}
got, err := u.GetUserRanking(tt.args.ctx)
if (err != nil) != tt.wantErr {
t.Errorf("UserService.GetUserRanking() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("UserService.GetUserRanking() = %v, want %v", got, tt.want)
}
})
}
}
4 changes: 1 addition & 3 deletions app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ go 1.21.1

require (
github.com/go-sql-driver/mysql v1.7.1
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.1
github.com/uptrace/bun v1.1.16
github.com/uptrace/bun/dialect/mysqldialect v1.1.16
github.com/uptrace/bunrouter v1.0.20
go.uber.org/mock v0.3.0
)

require (
github.com/cweill/gotests v1.6.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/tools v0.14.0 // indirect
)
Loading

0 comments on commit d8c3fcb

Please sign in to comment.