-
Notifications
You must be signed in to change notification settings - Fork 78
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
create test for internal/errors/errors.go #929
Conversation
[CHATOPS:HELP] ChatOps commands.
|
Codecov Report
@@ Coverage Diff @@
## master #929 +/- ##
==========================================
+ Coverage 14.24% 14.42% +0.18%
==========================================
Files 492 493 +1
Lines 27837 27904 +67
==========================================
+ Hits 3964 4025 +61
- Misses 23631 23632 +1
- Partials 242 247 +5
Continue to review full report at Codecov.
|
/rebase |
[REBASE] Rebase triggered by vankichi for branch: test/internal/add-newtest-for-errors-errors |
74d21ef
to
403f1e1
Compare
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.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
golangci
internal/errors/errors_test.go|538 col 10| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("logging retry")" (goerr113)
internal/errors/errors_test.go|545 col 5| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to output logs: logging retry")" (goerr113)
internal/errors/errors_test.go|554 col 5| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to output logs: logging retry")" (goerr113)
internal/errors/errors_test.go|566 col 5| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to output logs")" (goerr113)
internal/errors/errors_test.go|675 col 10| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err")" (goerr113)
internal/errors/errors_test.go|685 col 10| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err")" (goerr113)
internal/errors/errors_test.go|688 col 5| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err")" (goerr113)
internal/errors/errors_test.go|752 col 11| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err: ")" (goerr113)
internal/errors/errors_test.go|770 col 11| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err: ")" (goerr113)
internal/errors/errors_test.go|789 col 11| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err: ")" (goerr113)
internal/errors/errors_test.go|844 col 6| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(format, val...)" (goerr113)
internal/errors/errors_test.go|856 col 6| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New(format)" (goerr113)
internal/errors/errors_test.go|878 col 6| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%v %v", val[0], val[1])" (goerr113)
internal/errors/errors_test.go|892 col 6| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%v", val[0])" (goerr113)
internal/errors/errors_test.go|1185 col 2| S1008: should use 'return err.err.Error() == e.Error()' instead of 'if err.err.Error() == e.Error() { return true }; return false' (gosimple)
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.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
golangci
internal/errors/errors_test.go|747 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err")" (goerr113)
internal/errors/errors_test.go|751 col 11| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err")" (goerr113)
internal/errors/errors_test.go|759 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("error is occurred")" (goerr113)
internal/errors/errors_test.go|914 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(format, val...)" (goerr113)
internal/errors/errors_test.go|928 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New(format)" (goerr113)
internal/errors/errors_test.go|951 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%v %v", val[0], val[1])" (goerr113)
internal/errors/errors_test.go|966 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%v", val[0])" (goerr113)
internal/errors/errors_test.go|178 col 7| S1021: should merge variable declaration with assignment on next line (gosimple)
internal/errors/errors_test.go|194 col 7| S1021: should merge variable declaration with assignment on next line (gosimple)
internal/errors/errors_test.go
Outdated
} | ||
defaultCheckFunc := func(w want, got error) error { | ||
if !Is(got, w.want) { | ||
fmt.Println(got) |
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.
🚫 [golangci] reported by reviewdog 🐶
use of fmt.Println
forbidden by pattern ^fmt\.Print(|f|ln)$
(forbidigo)
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.
fmt.Println(got) |
internal/errors/errors_test.go
Outdated
err: errors.New("option failed error"), | ||
ref: func() reflect.Value { | ||
var i interface{} | ||
i = fmt.Println |
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.
🚫 [golangci] reported by reviewdog 🐶
use of fmt.Println
forbidden by pattern ^fmt\.Print(|f|ln)$
(forbidigo)
} | ||
}(), | ||
func() test { | ||
wantErr := errors.New("failed to output logs, retrying...") |
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.
🚫 [golangci] reported by reviewdog 🐶
error strings should not be capitalized or end with punctuation or a newline (golint)
ErrBackoffTimeout = func(err error) error { | ||
return Wrap(err, "backoff timeout by limitation") | ||
} | ||
|
||
// ErrInvalidTypeConversion represents a function to generate an error that type conversion fails due to an invalid input type. |
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.
🚫 [golangci] reported by reviewdog 🐶
line is 128 characters (lll)
want: want{}, | ||
}, | ||
{ | ||
name: "return true when err is wrapped comparable error and target is uncomparable error and err.err.Error() and target msg are same.", |
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.
🚫 [golangci] reported by reviewdog 🐶
line is 138 characters (lll)
"invalid time_duration", | ||
10, | ||
} | ||
wantErr := fmt.Errorf("%v %v", val[0], val[1]) |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%v %v", val[0], val[1])" (goerr113)
internal/errors/errors_test.go
Outdated
args: args{ | ||
err: errors.New("option failed error"), | ||
ref: func() reflect.Value { | ||
var i interface{} |
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.
🚫 [golangci] reported by reviewdog 🐶
S1021: should merge variable declaration with assignment on next line (gosimple)
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.
LGTM
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.
LGTM
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.
LGTM
args: args{ | ||
err: errors.New("option failed error"), | ||
ref: func() reflect.Value { | ||
var i interface{} = fmt.Println |
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.
🚫 [golangci] reported by reviewdog 🐶
use of fmt.Println
forbidden by pattern ^fmt\.Print(|f|ln)$
(forbidigo)
internal/errors/errors_test.go
Outdated
name: "return an ErrOptionFailed error when err is empty and ref is not empty.", | ||
args: args{ | ||
ref: func() reflect.Value { | ||
var i interface{} = fmt.Println |
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.
🚫 [golangci] reported by reviewdog 🐶
use of fmt.Println
forbidden by pattern ^fmt\.Print(|f|ln)$
(forbidigo)
args: args{ | ||
err: errors.New("logging retry"), | ||
ref: func() reflect.Value { | ||
var i interface{} = fmt.Println |
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.
🚫 [golangci] reported by reviewdog 🐶
use of fmt.Println
forbidden by pattern ^fmt\.Print(|f|ln)$
(forbidigo)
} | ||
tests := []test{ | ||
func() test { | ||
wantErr := errors.New("failed to output fmt.Println logs, retrying...: logging retry") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to output fmt.Println logs, retrying...: logging retry")" (goerr113)
} | ||
tests := []test{ | ||
func() test { | ||
wantErr := errors.New("failed to output fmt.Println logs: logging retry") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to output fmt.Println logs: logging retry")" (goerr113)
} | ||
}(), | ||
func() test { | ||
wantErr := errors.New("failed to output logs") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to output logs")" (goerr113)
/rebase |
[REBASE] Rebase triggered by kevindiu for branch: test/internal/add-newtest-for-errors-errors |
e2fc946
to
92d17a1
Compare
[FORMAT] Updating license headers and formatting go codes triggered by kevindiu. |
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.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
golangci
internal/errors/errors_test.go|767 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err")" (goerr113)
internal/errors/errors_test.go|771 col 11| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err")" (goerr113)
internal/errors/errors_test.go|779 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("error is occurred")" (goerr113)
internal/errors/errors_test.go|844 col 11| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err: ")" (goerr113)
internal/errors/errors_test.go|863 col 11| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err: ")" (goerr113)
internal/errors/errors_test.go|883 col 11| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err: ")" (goerr113)
internal/errors/errors_test.go|934 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(format, val...)" (goerr113)
internal/errors/errors_test.go|948 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "errors.New(format)" (goerr113)
internal/errors/errors_test.go|971 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%v %v", val[0], val[1])" (goerr113)
internal/errors/errors_test.go|986 col 15| err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%v", val[0])" (goerr113)
args: args{ | ||
err: errors.New("option failed error"), | ||
ref: func() reflect.Value { | ||
var i interface{} = fmt.Println |
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.
🚫 [golangci] reported by reviewdog 🐶
use of fmt.Println
forbidden by pattern ^fmt\.Print(|f|ln)$
(forbidigo)
}(), | ||
func() test { | ||
err := errors.New("err: ") | ||
format := "error is occurred: %v : %v" |
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.
🚫 [golangci] reported by reviewdog 🐶
string error is occurred: %v : %v
has 5 occurrences, make it a constant (goconst)
} | ||
tests := []test{ | ||
func() test { | ||
wantErr := errors.New("invalid timeout value: 10hours\t:timeout parse error out put failed") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("invalid timeout value: 10hours\t:timeout parse error out put failed")" (goerr113)
} | ||
}(), | ||
func() test { | ||
wantErr := errors.New("invalid timeout value: \t:timeout parse error out put failed") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("invalid timeout value: \t:timeout parse error out put failed")" (goerr113)
} | ||
tests := []test{ | ||
func() test { | ||
wantErr := errors.New("server gateway.vald.svc.cluster.local not found") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("server gateway.vald.svc.cluster.local not found")" (goerr113)
} | ||
}(), | ||
func() test { | ||
wantErr := errors.New("failed to output logs: logging retry") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to output logs: logging retry")" (goerr113)
} | ||
}(), | ||
func() test { | ||
wantErr := errors.New("failed to output logs") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to output logs")" (goerr113)
} | ||
tests := []test{ | ||
func() test { | ||
wantErr := errors.New("error is occurred") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("error is occurred")" (goerr113)
} | ||
tests := []test{ | ||
func() test { | ||
wantErr := fmt.Errorf("error is occurred: err") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("error is occurred: err")" (goerr113)
return test{ | ||
name: "return an error when err and msg are not empty.", | ||
args: args{ | ||
err: errors.New("err"), |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("err")" (goerr113)
} | ||
}(), | ||
func() test { | ||
wantErr := errors.New("failed to setup option :\t") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to setup option :\t")" (goerr113)
} | ||
}(), | ||
func() test { | ||
wantErr := errors.New("failed to setup option :\t") |
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.
🚫 [golangci] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New("failed to setup option :\t")" (goerr113)
/rebase |
[REBASE] Rebase triggered by kevindiu for branch: test/internal/add-newtest-for-errors-errors |
Signed-off-by: vankichi <kyukawa315@gmail.com>
Signed-off-by: vankichi <kyukawa315@gmail.com>
Co-authored-by: Hiroto Funakoshi <hiroto.funakoshi.hiroto@gmail.com>
Signed-off-by: vankichi <kyukawa315@gmail.com>
Signed-off-by: vankichi <kyukawa315@gmail.com>
Signed-off-by: vankichi <kyukawa315@gmail.com>
Signed-off-by: vankichi <kyukawa315@gmail.com>
Co-authored-by: Kevin Diu <kevindiujp@gmail.com>
Signed-off-by: vankichi <kyukawa315@gmail.com>
Signed-off-by: vdaas-ci <ci@vdaas.org>
Signed-off-by: vankichi <kyukawa315@gmail.com>
b87bd68
to
f35b9f0
Compare
[FORMAT] Updating license headers and formatting go codes triggered by kevindiu. |
/approve |
Signed-off-by: vankichi kyukawa315@gmail.com
I created the unit test for
internal/errors/errors.go
.And refactored the functions of
internal/errors/errors.go
which areErrOptionFailed
,ErrLoggingRetry
, andErrLoggingFailed
.also, grammar check by grammarly is completed.
Description:
Related Issue:
How Has This Been Tested?:
Environment:
Types of changes:
Changes to Core Features:
Checklist: