1
0
mirror of https://github.com/mgechev/revive.git synced 2025-02-13 13:48:36 +02:00
revive/rule/blank-imports_test.go

47 lines
716 B
Go
Raw Normal View History

2018-01-21 18:04:41 -08:00
package rule
2017-11-26 18:58:15 -08:00
import (
"testing"
"github.com/mgechev/revive/rule"
"github.com/mgechev/revive/testutil"
)
func TestBlankImports(t *testing.T) {
t.Parallel()
program := `
package foo
import (
"fmt"
/* MATCH /blank import/ */ [@f1]_ "os"[/@f1]
/* MATCH /blank import/ */ [@f2]_ "net/http"[/@f2]
_ "path"
)
`
testutil.AssertFailures(t, program, &BlankImportsRule{}, rule.Arguments{})
}
func TestBlankImports_ShouldSkipMain(t *testing.T) {
t.Parallel()
program := `
package main
import (
"fmt"
/* MATCH /blank import/ */ _ "os"
/* MATCH /blank import/ */ _ "net/http"
_ "path"
)
`
testutil.AssertSuccess(t, program, &BlankImportsRule{}, rule.Arguments{})
}