Rename DeleteClientID to DeleteClientByID

This commit is contained in:
Jannis Mattheis 2018-02-10 23:07:34 +01:00 committed by Jannis Mattheis
parent b8b15040f9
commit e44970e684
3 changed files with 7 additions and 7 deletions

View File

@ -51,8 +51,8 @@ func (_m *MockTokenDatabase) DeleteApplicationByID(id string) error {
return r0
}
// DeleteClientID provides a mock function with given fields: id
func (_m *MockTokenDatabase) DeleteClientID(id string) error {
// DeleteClientByID provides a mock function with given fields: id
func (_m *MockTokenDatabase) DeleteClientByID(id string) error {
ret := _m.Called(id)
var r0 error

View File

@ -18,7 +18,7 @@ type TokenDatabase interface {
CreateClient(client *model.Client) error
GetClientByID(id string) *model.Client
GetClientsByUser(userID uint) []*model.Client
DeleteClientID(id string) error
DeleteClientByID(id string) error
}
// The TokenAPI provides handlers for managing clients and applications.
@ -76,7 +76,7 @@ func (a *TokenAPI) DeleteApplication(ctx *gin.Context) {
func (a *TokenAPI) DeleteClient(ctx *gin.Context) {
clientID := ctx.Param("id")
if client := a.DB.GetClientByID(clientID); client != nil && client.UserID == auth.GetUserID(ctx) {
a.DB.DeleteClientID(clientID)
a.DB.DeleteClientByID(clientID)
} else {
ctx.AbortWithError(404, fmt.Errorf("client with id %s doesn't exists", clientID))
}

View File

@ -210,7 +210,7 @@ func (s *TokenSuite) Test_DeleteClient_expectNotFoundOnCurrentUserIsNotOwner() {
s.a.DeleteClient(s.ctx)
s.db.AssertNotCalled(s.T(), "DeleteClientID", mock.Anything)
s.db.AssertNotCalled(s.T(), "DeleteClientByID", mock.Anything)
assert.Equal(s.T(), 404, s.recorder.Code)
}
@ -268,7 +268,7 @@ func (s *TokenSuite) Test_DeleteClient_expectNotFound() {
s.ctx.Request = httptest.NewRequest("DELETE", "/token/"+firstClientToken, nil)
s.ctx.Params = gin.Params{{Key: "id", Value: firstClientToken}}
s.db.On("DeleteClientID", firstClientToken).Return(errors.New("what? that does not exist"))
s.db.On("DeleteClientByID", firstClientToken).Return(errors.New("what? that does not exist"))
s.db.On("GetClientByID", firstClientToken).Return(nil)
s.a.DeleteClient(s.ctx)
@ -281,7 +281,7 @@ func (s *TokenSuite) Test_DeleteClient() {
s.ctx.Request = httptest.NewRequest("DELETE", "/token/"+firstClientToken, nil)
s.ctx.Params = gin.Params{{Key: "id", Value: firstClientToken}}
s.db.On("DeleteClientID", firstClientToken).Return(nil)
s.db.On("DeleteClientByID", firstClientToken).Return(nil)
s.db.On("GetClientByID", firstClientToken).Return(&model.Client{ID: firstClientToken, Name: "custom_name", UserID: 5})
s.a.DeleteClient(s.ctx)