...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package repo_test
16
17 import (
18 "fmt"
19 "go/build"
20 "os"
21 "path/filepath"
22 "testing"
23
24 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo"
25 )
26
27 func TestGetRepoRoot(t *testing.T) {
28 repoRoot, err := repo.GetRoot()
29 if err != nil {
30 t.Errorf("error getting root: %v", err)
31 }
32 expectedPath := fmt.Sprintf("%v%v%v", build.Default.GOPATH, string(filepath.Separator), "src/github.com/GoogleCloudPlatform/k8s-config-connector")
33 if repoRoot != expectedPath {
34 t.Errorf("unexpected value for repoRoot: got '%v', want '%v'", repoRoot, expectedPath)
35 }
36 }
37
38 func TestGetCallerPackagePath(t *testing.T) {
39 path, err := repo.GetCallerPackagePath()
40 if err != nil {
41 t.Errorf("error getting package path: %v", err)
42 }
43 expectedPath, err := os.Getwd()
44 if err != nil {
45 t.Fatalf("error getting working directory: %v", err)
46 }
47 if path != expectedPath {
48 t.Errorf("unexpected value for path: got '%v', want '%v'", path, expectedPath)
49 }
50 }
51
View as plain text