-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring + error handling fixes #159
Conversation
… on 2xx responses.
…= nil` are unreachable code.
err = decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) | ||
if err == nil { | ||
return localVarReturnValue, localVarHttpResponse, err | ||
} | ||
} | ||
if localVarHttpResponse.StatusCode >= 300 { | ||
newErr := fmt.Errorf(string(localVarBody)) | ||
if localVarHttpResponse.StatusCode == 200 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more dead code
assert.Fail(t, "err is not of type GenericSwaggerError") | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some tests to check executor error responses
@@ -426,7 +427,10 @@ func (e *WorkflowExecutor) UpdateTask(taskId string, workflowInstanceId string, | |||
return err | |||
} | |||
taskResult.Status = status | |||
e.taskClient.UpdateTask(context.Background(), taskResult) | |||
_, _, err = e.taskClient.UpdateTask(context.Background(), taskResult) | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
executor.UpdateTask
was not handling errors properly
context.Background(), | ||
overwrite, | ||
*workflow, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
if response.StatusCode > 299 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These checks after
if err != nil {
return err
}
don't make sense. err
is going to be not nil and this line won't be reached.
1c79d79
to
e25db64
Compare
if err != nil { | ||
return err | ||
} | ||
if response.StatusCode != 200 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unreachable code
) | ||
|
||
type UserClient interface { | ||
CheckPermissions(ctx context.Context, userId string, type_ string, id string) (map[string]interface{}, *http.Response, error) | ||
DeleteUser(ctx context.Context, id string) (*http.Response, error) | ||
GetGrantedPermissions(ctx context.Context, userId string) ([]rbac.GrantedAccess, *http.Response, error) | ||
GetGrantedPermissions(ctx context.Context, userId string) (rbac.GrantedAccessResponse, *http.Response, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type was wrong. Because of buggy error handling this was not caught by the tests before
@@ -33,7 +33,7 @@ func TestDeleteEnvVariable(t *testing.T) { | |||
message, resp, err := envClient.DeleteEnvVariable(ctx, "testKey") | |||
assert.NoError(t, err) | |||
assert.NotNil(t, resp) | |||
assert.Equal(t, "", message) | |||
assert.Equal(t, "test value", message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"test value"
should have been the expected value of the test.
But, the backend is returning the environment variable value when deleting as string but the content-type is application/json
…g after code handling changes.
7bf109d
to
365e1a6
Compare
Follow up of #157
Changes in this PR
UserClient.GetGrantedPermissions()
implementation.For more details take a look at the comments.
TODO: More testing (in a next PR)