mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
4cdb38c072
Updates #448
24 lines
449 B
Go
24 lines
449 B
Go
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestFindExistingPackage(t *testing.T) {
|
|
path := findPackage("github.com/spf13/cobra")
|
|
if path == "" {
|
|
t.Fatal("findPackage didn't find the existing package")
|
|
}
|
|
if !hasGoPathPrefix(path) {
|
|
t.Fatalf("%q is not in GOPATH, but must be", path)
|
|
}
|
|
}
|
|
|
|
func hasGoPathPrefix(path string) bool {
|
|
for _, srcPath := range srcPaths {
|
|
if filepathHasPrefix(path, srcPath) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|