mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* [MM-11345] Migrated TokenStore.RemoveAllTokensByType to Sync by default (#11345) * changed TokenStore.RemoveAllTokensByType to return *model.AppError * changed test coverage accordingly in store/storetest/mocks * Fixing mocks
This commit is contained in:
@@ -72,11 +72,9 @@ func (s SqlTokenStore) Cleanup() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s SqlTokenStore) RemoveAllTokensByType(tokenType string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if _, err := s.GetMaster().Exec("DELETE FROM Tokens WHERE Type = :TokenType", map[string]interface{}{"TokenType": tokenType}); err != nil {
|
||||
result.Err = model.NewAppError("SqlTokenStore.RemoveAllTokensByType", "store.sql_recover.remove_all_tokens_by_type.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
})
|
||||
func (s SqlTokenStore) RemoveAllTokensByType(tokenType string) *model.AppError {
|
||||
if _, err := s.GetMaster().Exec("DELETE FROM Tokens WHERE Type = :TokenType", map[string]interface{}{"TokenType": tokenType}); err != nil {
|
||||
return model.NewAppError("SqlTokenStore.RemoveAllTokensByType", "store.sql_recover.remove_all_tokens_by_type.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ type TokenStore interface {
|
||||
Delete(token string) *model.AppError
|
||||
GetByToken(token string) (*model.Token, *model.AppError)
|
||||
Cleanup()
|
||||
RemoveAllTokensByType(tokenType string) StoreChannel
|
||||
RemoveAllTokensByType(tokenType string) *model.AppError
|
||||
}
|
||||
|
||||
type EmojiStore interface {
|
||||
|
||||
@@ -6,7 +6,6 @@ package mocks
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
import model "github.com/mattermost/mattermost-server/model"
|
||||
import store "github.com/mattermost/mattermost-server/store"
|
||||
|
||||
// TokenStore is an autogenerated mock type for the TokenStore type
|
||||
type TokenStore struct {
|
||||
@@ -60,15 +59,15 @@ func (_m *TokenStore) GetByToken(token string) (*model.Token, *model.AppError) {
|
||||
}
|
||||
|
||||
// RemoveAllTokensByType provides a mock function with given fields: tokenType
|
||||
func (_m *TokenStore) RemoveAllTokensByType(tokenType string) store.StoreChannel {
|
||||
func (_m *TokenStore) RemoveAllTokensByType(tokenType string) *model.AppError {
|
||||
ret := _m.Called(tokenType)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||
r0 = rf(tokenType)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user