@@ -3532,24 +3532,43 @@ func TestImportLocal(t *testing.T) {
3532
3532
}
3533
3533
3534
3534
func TestGoGetInsecure (t * testing.T ) {
3535
- testenv .MustHaveExternalNetwork (t )
3535
+ test := func (t * testing.T , modules bool ) {
3536
+ testenv .MustHaveExternalNetwork (t )
3536
3537
3537
- tg := testgo (t )
3538
- defer tg .cleanup ()
3539
- tg .makeTempdir ()
3540
- tg .setenv ("GOPATH" , tg .path ("." ))
3541
- tg .failSSH ()
3538
+ tg := testgo (t )
3539
+ defer tg .cleanup ()
3540
+ tg .makeTempdir ()
3541
+ tg .failSSH ()
3542
3542
3543
- const repo = "insecure.go-get-issue-15410.appspot.com/pkg/p"
3543
+ if modules {
3544
+ tg .setenv ("GOPATH" , tg .path ("gp" ))
3545
+ tg .tempFile ("go.mod" , "module m" )
3546
+ tg .cd (tg .path ("." ))
3547
+ tg .setenv ("GO111MODULE" , "on" )
3548
+ } else {
3549
+ tg .setenv ("GOPATH" , tg .path ("." ))
3550
+ tg .setenv ("GO111MODULE" , "off" )
3551
+ }
3544
3552
3545
- // Try go get -d of HTTP-only repo (should fail).
3546
- tg .runFail ("get" , "-d" , repo )
3553
+ const repo = "insecure.go-get-issue-15410.appspot.com/pkg/p"
3547
3554
3548
- // Try again with -insecure (should succeed).
3549
- tg .run ("get" , "-d" , "-insecure" , repo )
3555
+ // Try go get -d of HTTP-only repo (should fail).
3556
+ tg .runFail ("get" , "-d" , repo )
3557
+
3558
+ // Try again with -insecure (should succeed).
3559
+ tg .run ("get" , "-d" , "-insecure" , repo )
3560
+
3561
+ // Try updating without -insecure (should fail).
3562
+ tg .runFail ("get" , "-d" , "-u" , "-f" , repo )
3563
+
3564
+ if modules {
3565
+ tg .run ("list" , "-m" , "..." )
3566
+ tg .grepStdout ("insecure.go-get-issue" , "should find insecure module" )
3567
+ }
3568
+ }
3550
3569
3551
- // Try updating without -insecure (should fail).
3552
- tg . runFail ( "get " , "-d" , "-u" , "-f" , repo )
3570
+ t . Run ( "gopath" , func ( t * testing. T ) { test ( t , false ) })
3571
+ t . Run ( "modules " , func ( t * testing. T ) { test ( t , true ) } )
3553
3572
}
3554
3573
3555
3574
func TestGoGetUpdateInsecure (t * testing.T ) {
0 commit comments