summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/cobra/cobra/cmd/project_test.go
blob: 037f7c554e5063204953674967f54f8b1c495afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
}