@@ -305,6 +305,7 @@ func TestCollectConstraints(t *testing.T) {
305
305
ver1 , _ := gps .NewSemverConstraintIC ("v1.0.0" )
306
306
ver08 , _ := gps .NewSemverConstraintIC ("v0.8.0" )
307
307
ver2 , _ := gps .NewSemverConstraintIC ("v2.0.0" )
308
+ master := gps .NewBranch ("master" )
308
309
309
310
cases := []struct {
310
311
name string
@@ -387,15 +388,18 @@ func TestCollectConstraints(t *testing.T) {
387
388
lock : dep.Lock {
388
389
P : []gps.LockedProject {
389
390
gps .NewLockedProject (
390
- gps.ProjectIdentifier {ProjectRoot : gps .ProjectRoot ("github.com/JackyChiu/deptest " )},
391
+ gps.ProjectIdentifier {ProjectRoot : gps .ProjectRoot ("github.com/JackyChiu/dep-applicable-constraints " )},
391
392
gps .NewVersion ("v1.0.0" ),
392
393
[]string {"." },
393
394
),
394
395
},
395
396
},
396
397
wantConstraints : constraintsCollection {
398
+ "github.com/boltdb/bolt" : []projectConstraint {
399
+ {"github.com/JackyChiu/dep-applicable-constraints" , master },
400
+ },
397
401
"github.com/sdboyer/deptest" : []projectConstraint {
398
- {"github.com/JackyChiu/deptest " , ver08 },
402
+ {"github.com/JackyChiu/dep-applicable-constraints " , ver08 },
399
403
},
400
404
},
401
405
},
@@ -406,6 +410,17 @@ func TestCollectConstraints(t *testing.T) {
406
410
407
411
h .TempDir ("src" )
408
412
pwd := h .Path ("." )
413
+ h .TempFile (filepath .Join ("src" , "dep.go" ), `
414
+ package dep
415
+ import (
416
+ _ "github.com/boltdb/bolt"
417
+ _ "github.com/sdboyer/deptest"
418
+ _ "github.com/sdboyer/dep-test"
419
+ _ "github.com/sdboyer/deptestdos"
420
+ )
421
+ type FooBar int
422
+ ` )
423
+
409
424
discardLogger := log .New (ioutil .Discard , "" , 0 )
410
425
411
426
ctx := & dep.Ctx {
@@ -440,65 +455,6 @@ func TestCollectConstraints(t *testing.T) {
440
455
}
441
456
}
442
457
443
- func TestProjectImports (t * testing.T ) {
444
- cases := []struct {
445
- name string
446
- proj gps.LockedProject
447
- expected map [string ]bool
448
- }{
449
- {
450
- name : "no imports" ,
451
- proj : gps .NewLockedProject (
452
- gps.ProjectIdentifier {ProjectRoot : gps .ProjectRoot ("github.com/sdboyer/deptest" )},
453
- gps .NewVersion ("v1.0.0" ),
454
- []string {"." },
455
- ),
456
- expected : map [string ]bool {},
457
- },
458
- {
459
- name : "mutilple imports" ,
460
- proj : gps .NewLockedProject (
461
- gps.ProjectIdentifier {ProjectRoot : gps .ProjectRoot ("github.com/darkowlzz/deptest-project-1" )},
462
- gps .NewVersion ("v0.1.0" ),
463
- []string {"." },
464
- ),
465
- expected : map [string ]bool {
466
- "fmt" : true ,
467
- "github.com/sdboyer/deptest" : true ,
468
- },
469
- },
470
- }
471
-
472
- h := test .NewHelper (t )
473
- defer h .Cleanup ()
474
-
475
- h .TempDir ("src" )
476
- pwd := h .Path ("." )
477
- discardLogger := log .New (ioutil .Discard , "" , 0 )
478
-
479
- ctx := & dep.Ctx {
480
- GOPATH : pwd ,
481
- Out : discardLogger ,
482
- Err : discardLogger ,
483
- }
484
-
485
- sm , err := ctx .SourceManager ()
486
- h .Must (err )
487
- defer sm .Release ()
488
-
489
- for _ , c := range cases {
490
- t .Run (c .name , func (t * testing.T ) {
491
- imports , err := projectImports (sm , c .proj )
492
- if err != nil {
493
- t .Fatalf ("unexpected error while getting project imports: %v" , err )
494
- }
495
- if ! reflect .DeepEqual (imports , c .expected ) {
496
- t .Fatalf ("unexpected project imports: \n \t (GOT): %v\n \t (WNT): %v" , imports , c .expected )
497
- }
498
- })
499
- }
500
- }
501
-
502
458
func TestValidateFlags (t * testing.T ) {
503
459
testCases := []struct {
504
460
name string
0 commit comments