2019-04-28 04:23:17 +02:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-04-30 04:56:12 +02:00
|
|
|
"github.com/mgechev/revive/lint"
|
2019-04-28 04:23:17 +02:00
|
|
|
"github.com/mgechev/revive/rule"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUnhandledError(t *testing.T) {
|
|
|
|
testRule(t, "unhandled-error", &rule.UnhandledErrorRule{})
|
|
|
|
}
|
2019-04-30 04:56:12 +02:00
|
|
|
|
2022-11-09 14:13:52 +02:00
|
|
|
func TestUnhandledErrorWithIgnoreList(t *testing.T) {
|
2023-09-24 08:44:02 +02:00
|
|
|
args := []any{
|
2022-11-09 14:13:52 +02:00
|
|
|
`unhandledError1`,
|
|
|
|
`fmt\.Print`,
|
|
|
|
`os\.(Create|WriteFile|Chmod)`,
|
|
|
|
`net\..*`,
|
|
|
|
`bytes\.Buffer\.Write`,
|
|
|
|
`fixtures\.unhandledErrorStruct2\.reterr`,
|
|
|
|
}
|
2019-04-30 04:56:12 +02:00
|
|
|
|
|
|
|
testRule(t, "unhandled-error-w-ignorelist", &rule.UnhandledErrorRule{}, &lint.RuleConfig{Arguments: args})
|
|
|
|
}
|