@@ -17,6 +17,29 @@ import (
17
17
18
18
const testGbProjectRoot = "github.com/golang/notexist"
19
19
20
+ func TestGbConfig_ImportNoVendor (t * testing.T ) {
21
+ h := test .NewHelper (t )
22
+ defer h .Cleanup ()
23
+
24
+ ctx := newTestContext (h )
25
+ sm , err := ctx .SourceManager ()
26
+ h .Must (err )
27
+ defer sm .Release ()
28
+
29
+ h .TempDir (filepath .Join ("src" , testGbProjectRoot , "vendor" ))
30
+ h .TempCopy (filepath .Join (testGbProjectRoot , "vendor" , "_not-a-manifest" ), "gb/manifest" )
31
+ projectRoot := h .Path (testGbProjectRoot )
32
+
33
+ // Capture stderr so we can verify output
34
+ verboseOutput := & bytes.Buffer {}
35
+ ctx .Err = log .New (verboseOutput , "" , 0 )
36
+
37
+ g := newGbImporter (ctx .Err , false , sm ) // Disable verbose so that we don't print values that change each test run
38
+ if g .HasDepMetadata (projectRoot ) {
39
+ t .Fatal ("Expected the importer to return false if there's no vendor manifest" )
40
+ }
41
+ }
42
+
20
43
func TestGbConfig_Import (t * testing.T ) {
21
44
h := test .NewHelper (t )
22
45
defer h .Cleanup ()
@@ -35,6 +58,9 @@ func TestGbConfig_Import(t *testing.T) {
35
58
ctx .Err = log .New (verboseOutput , "" , 0 )
36
59
37
60
g := newGbImporter (ctx .Err , false , sm ) // Disable verbose so that we don't print values that change each test run
61
+ if g .Name () != "gb" {
62
+ t .Fatal ("Expected the importer to return the name 'gb'" )
63
+ }
38
64
if ! g .HasDepMetadata (projectRoot ) {
39
65
t .Fatal ("Expected the importer to detect the gb manifest file" )
40
66
}
@@ -144,7 +170,7 @@ func TestGbConfig_Convert_Project(t *testing.T) {
144
170
}
145
171
}
146
172
147
- func TestGbConfig_Convert_BadInput_EmptyPackageName (t * testing.T ) {
173
+ func TestGbConfig_Convert_BadInput (t * testing.T ) {
148
174
h := test .NewHelper (t )
149
175
defer h .Cleanup ()
150
176
@@ -162,4 +188,14 @@ func TestGbConfig_Convert_BadInput_EmptyPackageName(t *testing.T) {
162
188
if err == nil {
163
189
t .Fatal ("Expected conversion to fail because the package name is empty" )
164
190
}
191
+
192
+ g = newGbImporter (ctx .Err , true , sm )
193
+ g .manifest = gbManifest {
194
+ Dependencies : []gbDependency {{Importpath : "github.com/sdboyer/deptest" }},
195
+ }
196
+
197
+ _ , _ , err = g .convert (testGbProjectRoot )
198
+ if err == nil {
199
+ t .Fatal ("Expected conversion to fail because the package has no revision" )
200
+ }
165
201
}
0 commit comments