github.com/gwaycc/gometalinter@v3.0.0+incompatible/regressiontests/dupl_test.go (about) 1 package regressiontests 2 3 import "testing" 4 5 func TestDupl(t *testing.T) { 6 t.Parallel() 7 source := `package test 8 9 func findVendoredLinters() string { 10 gopaths := strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) 11 for _, home := range vendoredSearchPaths { 12 for _, p := range gopaths { 13 joined := append([]string{p, "src"}, home...) 14 vendorRoot := filepath.Join(joined...) 15 fmt.Println(vendorRoot) 16 if _, err := os.Stat(vendorRoot); err == nil { 17 return vendorRoot 18 } 19 } 20 } 21 return "" 22 23 } 24 25 func two() string { 26 gopaths := strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) 27 for _, home := range vendoredSearchPaths { 28 for _, p := range gopaths { 29 joined := append([]string{p, "src"}, home...) 30 vendorRoot := filepath.Join(joined...) 31 fmt.Println(vendorRoot) 32 if _, err := os.Stat(vendorRoot); err == nil { 33 return vendorRoot 34 } 35 } 36 } 37 return "" 38 39 } 40 ` 41 42 expected := Issues{ 43 {Linter: "dupl", Severity: "warning", Path: "test.go", Line: 3, Col: 0, Message: "duplicate of test.go:19-33"}, 44 {Linter: "dupl", Severity: "warning", Path: "test.go", Line: 19, Col: 0, Message: "duplicate of test.go:3-17"}, 45 } 46 ExpectIssues(t, "dupl", source, expected) 47 }