mirror of
https://github.com/mgechev/revive.git
synced 2024-11-24 08:32:22 +02:00
26 lines
591 B
Go
26 lines
591 B
Go
|
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: []interface{}{[]interface{}{"return", "recover", "call-chain", "method-call"}},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func TestDeferOthersDisabled(t *testing.T) {
|
||
|
testRule(t, "defer-only-loop-enabled", &rule.DeferRule{}, &lint.RuleConfig{
|
||
|
Arguments: []interface{}{[]interface{}{"loop"}},
|
||
|
})
|
||
|
}
|