1
0
mirror of https://github.com/mgechev/revive.git synced 2024-12-02 09:02:23 +02:00
revive/test/defer_test.go

26 lines
559 B
Go
Raw Normal View History

2020-05-24 20:49:49 +02:00
package test
import (
"testing"
"github.com/mgechev/revive/lint"
"github.com/mgechev/revive/rule"
)
// Defer rule.
func TestDefer(t *testing.T) {
testRule(t, "defer", &rule.DeferRule{})
}
func TestDeferLoopDisabled(t *testing.T) {
testRule(t, "defer-loop-disabled", &rule.DeferRule{}, &lint.RuleConfig{
Arguments: []any{[]any{"return", "recover", "call-chain", "method-call"}},
2020-05-24 20:49:49 +02:00
})
}
func TestDeferOthersDisabled(t *testing.T) {
testRule(t, "defer-only-loop-enabled", &rule.DeferRule{}, &lint.RuleConfig{
Arguments: []any{[]any{"loop"}},
2020-05-24 20:49:49 +02:00
})
}