diff --git a/api/mock/mock_tokendatabase.go b/api/mock/mock_tokendatabase.go index d3568cb..77be5d7 100644 --- a/api/mock/mock_tokendatabase.go +++ b/api/mock/mock_tokendatabase.go @@ -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 diff --git a/api/token.go b/api/token.go index fe9415a..5554162 100644 --- a/api/token.go +++ b/api/token.go @@ -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)) } diff --git a/api/token_test.go b/api/token_test.go index f4eb991..f062bbd 100644 --- a/api/token_test.go +++ b/api/token_test.go @@ -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)