lostluck commented on a change in pull request #16934:
URL: https://github.com/apache/beam/pull/16934#discussion_r814276563
##########
File path: sdks/go/pkg/beam/internal/errors/errors_test.go
##########
@@ -147,10 +170,51 @@ func TestSetTopLevelMsgf(t *testing.T) {
}
}
+func TestSetTopLevelMsgf_NilErr(t *testing.T) {
+ want := ""
+ err := SetTopLevelMsgf(nil, "%s %d", "ten", 10)
+ if getTop(err) != want {
+ t.Errorf("Incorrect formatting. Want: %q, Got: %q", want,
getTop(err))
+ }
+}
+
+func TestError(t *testing.T) {
+ tests := []struct {
+ err error
+ want string
+ }{
+ {
+ err: Wrap(New(base), msg1),
+ want: "message 1\n\tcaused by:\nbase",
+ },
+ {
+ err: SetTopLevelMsg(New(base), top1),
+ want: "top level message 1\nFull error:\nbase",
+ },
+ {
+ err: SetTopLevelMsg(Wrap(Wrap(New(base), msg1), msg2),
top1),
+ want: "top level message 1\nFull error:\nmessage
2\n\tcaused by:\nmessage 1\n\tcaused by:\nbase",
+ },
+ }
+
+ for _, test := range tests {
+ if be, ok := test.err.(*beamError); ok {
+ if got, want := be.Error(), test.want; got != want {
+ t.Errorf("Incorrect formatting. Want: %q, Got:
%q", want, got)
+ }
+ } else {
+ t.Errorf("Error should be type beamError, got: %q",
test.err)
Review comment:
Types and their pointers are distinct types, even though the pointer
variant is derived. I'm going to commit the suggested edit but wanted to
clarify what it was I was doing.
```suggestion
t.Errorf("Error should be type *beamError, got: %q",
test.err)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]