@@ -18,23 +18,27 @@ func TestSelectedDependencyUpdatesIndirectWithoutMovingOthers(t *testing.T) {
1818 files := map [string ]string {
1919 "go.mod" : "module example.test/app\n go 1.23\n require (\n example.test/direct v1.0.0\n example.test/indirect v1.0.0 // indirect\n )\n replace example.test/direct => ./direct\n replace example.test/indirect => ./indirect\n " ,
2020 "app.go" : "package app\n import \" example.test/direct\" \n var Value = direct.Value\n " ,
21- "direct/go.mod" : "module example.test/direct\n go 1.23\n require example.test/indirect v1.0.0\n " ,
21+ "direct/go.mod" : "module example.test/direct\n go 1.23\n require example.test/indirect v1.0.0\n replace example.test/indirect => ../indirect \ n " ,
2222 "direct/direct.go" : "package direct\n import \" example.test/indirect\" \n var Value = indirect.Value\n " ,
2323 "indirect/go.mod" : "module example.test/indirect\n go 1.23\n " ,
2424 "indirect/indirect.go" : "package indirect\n const Value = 42\n " ,
2525 }
2626 for name , data := range files {
2727 path := filepath .Join (root , name )
28- require .NoError (t , os .MkdirAll (filepath .Dir (path ), 0755 ))
29- require .NoError (t , os .WriteFile (path , []byte (data ), 0644 ))
28+ require .NoError (t , os .MkdirAll (filepath .Dir (path ), 0o755 ))
29+ require .NoError (t , os .WriteFile (path , []byte (data ), 0o644 ))
3030 }
3131 // The existing module resolver is real; local replacements keep the fixture offline.
3232 pins , err := dependencypins .Plan ([]string {root , filepath .Join (root , "indirect" )}, []string {"example.test/indirect@v1.0.1" })
3333 require .NoError (t , err )
3434 require .Empty (t , pins [filepath .Join (root , "indirect" )], "do not inject a requirement into a module that never used it" )
35+ oldDir , oldAudit , oldSelections := depsDir , depsAudit , depsSelections
36+ t .Cleanup (func () { depsDir , depsAudit , depsSelections = oldDir , oldAudit , oldSelections })
37+ depsDir , depsAudit = root , false
38+ depsSelections = []string {"example.test/indirect@v1.0.1" }
3539 ctx , done := common .NewContext ()
3640 defer done ()
37- require .NoError (t , updateModule ( ctx , root , pins [ root ] ... ))
41+ require .NoError (t , DepsCmd . RunE ( DepsCmd , nil ))
3842 data , err := os .ReadFile (filepath .Join (root , "go.mod" ))
3943 require .NoError (t , err )
4044 parsed , err := modfile .Parse ("go.mod" , data , nil )
@@ -48,7 +52,8 @@ func TestSelectedDependencyUpdatesIndirectWithoutMovingOthers(t *testing.T) {
4852 require .NoError (t , runGo (ctx , root , "build" , "./..." ))
4953 require .NoError (t , runGo (ctx , root , "mod" , "tidy" , "-diff" ))
5054 before := string (data )
51- _ , err = dependencypins .Plan ([]string {root }, []string {"example.test/indirect@v1.0.2" , "example.test/missing@v1.0.1" })
55+ depsSelections = []string {"example.test/indirect@v1.0.2" , "example.test/missing@v1.0.1" }
56+ err = DepsCmd .RunE (DepsCmd , nil )
5257 require .Error (t , err )
5358 data , err = os .ReadFile (filepath .Join (root , "go.mod" ))
5459 require .NoError (t , err )
0 commit comments