MM-61519 Fix errcheck in channels/app/plugin_api_tests/test_update_user_auth_plugin/main.go (#29284)
* Removed test_update_user_auth_plugin from golangci The test_update_user_auth_plugin has been removed from the .golangci.yml configuration file. This change simplifies the linting process by excluding unnecessary files. * Refactored error handling in user auth tests The error handling for the 'expectUserAuth' function within the user authentication plugin tests has been refactored. Previously, errors were not being explicitly checked after each call to this function. Now, an error check is performed after each invocation and if an error is found, it's immediately returned. This change improves the robustness of our test suite by ensuring that potential issues are caught and handled appropriately during testing. * Refactor error handling in UpdateUserAuth The error handling in the UpdateUserAuth function has been refactored. The variable 'err' was replaced with 'appErr' to better reflect its purpose and improve code readability. * Updated user authentication in plugin API The user authentication method in the plugin API has been updated. Previously, it was fetching the user based on a static configuration value. Now, it fetches the user dynamically using the provided userID. This change makes the function more flexible and adaptable to different use cases. * Updated golangci configuration Removed a test file from the exclusion list in the golangci.yml configuration. This will allow linting checks to be performed on this previously excluded file, improving code quality and consistency. * Updated golangci configuration Removed a test file from the exclusion list in the golangci configuration. This will ensure that our linting tools also cover this previously excluded test file, improving overall code quality checks. --------- Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8f716a61e6
Коммит
f64402e5c5
@@ -117,7 +117,6 @@ issues:
|
||||
channels/app/platform/web_conn.go|\
|
||||
channels/app/platform/web_hub.go|\
|
||||
channels/app/platform/web_hub_test.go|\
|
||||
channels/app/plugin_api_tests/test_update_user_auth_plugin/main.go|\
|
||||
channels/app/plugin_install.go|\
|
||||
channels/app/plugin_signature.go|\
|
||||
channels/app/plugin_signature_test.go|\
|
||||
|
||||
@@ -24,7 +24,7 @@ func (p *MyPlugin) OnConfigurationChange() error {
|
||||
}
|
||||
|
||||
func (p *MyPlugin) expectUserAuth(userID string, expectedUserAuth *model.UserAuth) error {
|
||||
user, err := p.API.GetUser(p.configuration.BasicUserID)
|
||||
user, err := p.API.GetUser(userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -63,21 +63,33 @@ func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model
|
||||
return nil, appErr.Error()
|
||||
}
|
||||
|
||||
p.expectUserAuth(p.configuration.BasicUserID, expectedUserAuth)
|
||||
p.expectUserAuth(p.configuration.BasicUser2Id, expectedUser2Auth)
|
||||
err := p.expectUserAuth(p.configuration.BasicUserID, expectedUserAuth)
|
||||
if err != nil {
|
||||
return nil, err.Error()
|
||||
}
|
||||
err = p.expectUserAuth(p.configuration.BasicUser2Id, expectedUser2Auth)
|
||||
if err != nil {
|
||||
return nil, err.Error()
|
||||
}
|
||||
|
||||
// Update BasicUser to LDAP
|
||||
expectedUserAuth = &model.UserAuth{
|
||||
AuthService: model.UserAuthServiceLdap,
|
||||
AuthData: model.NewPointer("ldap_auth_data"),
|
||||
}
|
||||
_, err := p.API.UpdateUserAuth(p.configuration.BasicUserID, expectedUserAuth)
|
||||
_, appErr = p.API.UpdateUserAuth(p.configuration.BasicUserID, expectedUserAuth)
|
||||
if appErr != nil {
|
||||
return nil, appErr.Error()
|
||||
}
|
||||
|
||||
err = p.expectUserAuth(p.configuration.BasicUserID, expectedUserAuth)
|
||||
if err != nil {
|
||||
return nil, err.Error()
|
||||
}
|
||||
err = p.expectUserAuth(p.configuration.BasicUser2Id, expectedUser2Auth)
|
||||
if err != nil {
|
||||
return nil, err.Error()
|
||||
}
|
||||
|
||||
p.expectUserAuth(p.configuration.BasicUserID, expectedUserAuth)
|
||||
p.expectUserAuth(p.configuration.BasicUser2Id, expectedUser2Auth)
|
||||
|
||||
return nil, "OK"
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user