Skip to content

Commit

Permalink
✅ update runtime_test with feedback
Browse files Browse the repository at this point in the history
Signed-off-by: vankichi <[email protected]>
  • Loading branch information
vankichi committed Feb 8, 2021
1 parent 89254dc commit c847b89
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions internal/errors/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package errors

import (
"fmt"
"math"
"runtime"
"testing"
Expand Down Expand Up @@ -285,7 +284,7 @@ func TestErrPanicString(t *testing.T) {
}(),
func() test {
return test{
name: "return an error when err not nil and msg is not empty",
name: "return an error when err is nil and msg is not empty",
args: args{
msg: defaultMsg,
},
Expand All @@ -294,6 +293,15 @@ func TestErrPanicString(t *testing.T) {
},
}
}(),
func() test {
return test{
name: "return an error when err is nil and msg is empty",
args: args{},
want: want{
want: Wrap(nil, New("panic recovered: ").Error()),
},
}
}(),
}
for _, tc := range tests {
test := tc
Expand All @@ -318,8 +326,6 @@ func TestErrPanicString(t *testing.T) {
}
}

type runtimeError runtime.Error

type runtimeErr struct {
err error
}
Expand Down Expand Up @@ -391,6 +397,15 @@ func TestErrRuntimeError(t *testing.T) {
},
}
}(),
func() test {
return test{
name: "return an error when err is nil and msg is nil",
args: args{},
want: want{
want: Wrap(nil, Errorf("system panicked caused by runtime error: %v", nil).Error()),
},
}
}(),
}
for _, tc := range tests {
test := tc
Expand All @@ -406,7 +421,7 @@ func TestErrRuntimeError(t *testing.T) {
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}
fmt.Println(test.args.r)

got := ErrRuntimeError(test.args.err, test.args.r)
if err := test.checkFunc(test.want, got); err != nil {
tt.Errorf("error = %v", err)
Expand Down

0 comments on commit c847b89

Please sign in to comment.