5
5
package main
6
6
7
7
import (
8
+ "fmt"
8
9
"os"
9
10
"path/filepath"
10
11
"runtime"
11
12
"testing"
13
+
14
+ "github.com/sdboyer/gps"
12
15
)
13
16
14
17
func TestFindRoot (t * testing.T ) {
@@ -40,6 +43,20 @@ func TestFindRoot(t *testing.T) {
40
43
t .Errorf ("findProjectRoot on nonexistent subdir should still work and give %s, got %s" , expect , got3 )
41
44
}
42
45
46
+ root := "/"
47
+ returnedPath , projectRootErr := findProjectRoot (root )
48
+ if returnedPath != "" {
49
+ t .Errorf ("findProjectRoot with path %s returned non empty string: %s" , root , returnedPath )
50
+ }
51
+ if projectRootErr == nil {
52
+ t .Errorf ("findProjectRoot with path %s should return error" , root )
53
+ }
54
+ errStr := fmt .Sprintf ("%v" , projectRootErr .Error ())
55
+ expectedStr := "could not find project manifest.json, use dep init to initiate a manifest"
56
+ if errStr != expectedStr {
57
+ t .Errorf ("Incorrect errProjectNotFound error. Found: %s. Expected: %s" , errStr , expectedStr )
58
+ }
59
+
43
60
// the following test does not work on windows because syscall.Stat does not
44
61
// return a "not a directory" error
45
62
if runtime .GOOS != "windows" {
@@ -49,3 +66,22 @@ func TestFindRoot(t *testing.T) {
49
66
}
50
67
}
51
68
}
69
+
70
+ func TestProjectMakeParams (t * testing.T ) {
71
+ p := project {
72
+ absroot : "someroot" ,
73
+ importroot : gps .ProjectRoot ("Some project root" ),
74
+ m : & manifest {Ignores : []string {"ignoring this" }},
75
+ l : & lock {},
76
+ }
77
+
78
+ solveParam := p .makeParams ()
79
+
80
+ if solveParam .Manifest != p .m {
81
+ t .Error ("makeParams() returned gps.SolveParameters with incorrect Manifest" )
82
+ }
83
+
84
+ if solveParam .Lock != p .l {
85
+ t .Error ("makeParams() returned gps.SolveParameters with incorrect Lock" )
86
+ }
87
+ }
0 commit comments