1package cmd
2
3import (
4	"testing"
5)
6
7func TestFindExistingPackage(t *testing.T) {
8	path := findPackage("github.com/spf13/cobra")
9	if path == "" {
10		t.Fatal("findPackage didn't find the existing package")
11	}
12	if !hasGoPathPrefix(path) {
13		t.Fatalf("%q is not in GOPATH, but must be", path)
14	}
15}
16
17func hasGoPathPrefix(path string) bool {
18	for _, srcPath := range srcPaths {
19		if filepathHasPrefix(path, srcPath) {
20			return true
21		}
22	}
23	return false
24}
25