-
Notifications
You must be signed in to change notification settings - Fork 111
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
RDSK-9311: (gripper/input-controller) Guard against nil responses in rdk client/servers #4620
base: main
Are you sure you want to change the base?
Changes from all commits
392e425
517c7c3
434ee1c
5482948
eb8d23e
e2962cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,10 +61,10 @@ func TestClient(t *testing.T) { | |
|
||
injectInputController2 := &inject.InputController{} | ||
injectInputController2.ControlsFunc = func(ctx context.Context, extra map[string]interface{}) ([]input.Control, error) { | ||
return nil, errControlsFailed | ||
return nil, nil | ||
} | ||
injectInputController2.EventsFunc = func(ctx context.Context, extra map[string]interface{}) (map[input.Control]input.Event, error) { | ||
return nil, errEventsFailed | ||
return nil, nil | ||
} | ||
|
||
resources := map[resource.Name]input.Controller{ | ||
|
@@ -252,11 +252,11 @@ func TestClient(t *testing.T) { | |
|
||
_, err = client2.Controls(context.Background(), map[string]interface{}{}) | ||
test.That(t, err, test.ShouldNotBeNil) | ||
test.That(t, err.Error(), test.ShouldContainSubstring, errControlsFailed.Error()) | ||
test.That(t, err.Error(), test.ShouldContainSubstring, input.ErrControlsNil(failInputControllerName).Error()) | ||
|
||
_, err = client2.Events(context.Background(), map[string]interface{}{}) | ||
test.That(t, err, test.ShouldNotBeNil) | ||
test.That(t, err.Error(), test.ShouldContainSubstring, errEventsFailed.Error()) | ||
test.That(t, err.Error(), test.ShouldContainSubstring, input.ErrEventsNil(failInputControllerName).Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we still be testing the previous errors or is it not needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not needed because |
||
|
||
event1 := input.Event{ | ||
Time: time.Now().UTC(), | ||
|
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.
would
Errors.Is
work here? I think we are trying to avoid using substring for errors test when possibleThere 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 problem is that it adds
"rpc error: code = Unknown desc = "
before the actual error, so figured it was easier to use substring. in the server code it doesn't add that string, so you can just usetest.ShouldBeError
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.
although I guess I didn't try
Errors.Is
perhaps that's easier, I've never seen that in thetest.That()
format, I'll try it outThere 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.
makes sense thanks for explaining! I meant
test.ShouldBeError
so prob fine to leave as is