-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: change Handler to Controller, remove store from Controller
- Loading branch information
Showing
31 changed files
with
123 additions
and
174 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
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
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
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
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
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 |
---|---|---|
|
@@ -14,18 +14,16 @@ import ( | |
"github.com/golang/mock/gomock" | ||
|
||
srvv1 "github.com/marmotedu/iam/internal/apiserver/service/v1" | ||
"github.com/marmotedu/iam/internal/apiserver/store" | ||
) | ||
|
||
func TestUserHandler_Create(t *testing.T) { | ||
func TestUserController_Create(t *testing.T) { | ||
ctrl := gomock.NewController(t) | ||
defer ctrl.Finish() | ||
|
||
mockService := srvv1.NewMockService(ctrl) | ||
mockUserSrv := srvv1.NewMockUserSrv(ctrl) | ||
mockUserSrv.EXPECT().Create(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) | ||
mockService.EXPECT().Users().Return(mockUserSrv) | ||
mockFactory := store.NewMockFactory(ctrl) | ||
c, _ := gin.CreateTestContext(httptest.NewRecorder()) | ||
body := bytes.NewBufferString( | ||
`{"metadata":{"name":"admin"},"nickname":"admin","email":"[email protected]","password":"Admin@2020","phone":"1812884xxx"}`, | ||
|
@@ -34,8 +32,7 @@ func TestUserHandler_Create(t *testing.T) { | |
c.Request.Header.Set("Content-Type", "application/json") | ||
|
||
type fields struct { | ||
srv srvv1.Service | ||
store store.Factory | ||
srv srvv1.Service | ||
} | ||
type args struct { | ||
c *gin.Context | ||
|
@@ -48,8 +45,7 @@ func TestUserHandler_Create(t *testing.T) { | |
{ | ||
name: "default", | ||
fields: fields{ | ||
srv: mockService, | ||
store: mockFactory, | ||
srv: mockService, | ||
}, | ||
args: args{ | ||
c: c, | ||
|
@@ -58,9 +54,8 @@ func TestUserHandler_Create(t *testing.T) { | |
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
u := &UserHandler{ | ||
srv: tt.fields.srv, | ||
store: tt.fields.store, | ||
u := &UserController{ | ||
srv: tt.fields.srv, | ||
} | ||
u.Create(tt.args.c) | ||
}) | ||
|
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
Oops, something went wrong.