-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from MidraLab/feat/gotest-workflow
gotestsCiの追加
- Loading branch information
Showing
11 changed files
with
702 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.