Skip to content

Commit 23aaa19

Browse files
committed
chore: retrigger CI
1 parent 08b9841 commit 23aaa19

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

crosslink/internal/prune_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,36 @@ func TestPruneReplace(t *testing.T) {
190190
t.Errorf("Replace{} mismatch (-want +got):\n%s", diff)
191191
}
192192
}
193+
194+
func TestPruneReplace_SafeIteration(t *testing.T) {
195+
modContents := []byte(`module go.opentelemetry.io/build-tools/crosslink/testroot
196+
197+
go 1.20
198+
199+
replace go.opentelemetry.io/build-tools/crosslink/testroot/testA => ./testA
200+
replace go.opentelemetry.io/build-tools/crosslink/testroot/testB => ./testB
201+
replace go.opentelemetry.io/build-tools/crosslink/testroot/testC => ./testC
202+
replace go.opentelemetry.io/build-tools/crosslink/testroot/testD => ./testD
203+
`)
204+
205+
modFile, err := modfile.Parse("go.mod", modContents, nil)
206+
if err != nil {
207+
t.Fatalf("failed to parse mock gomod file: %v", err)
208+
}
209+
210+
mockModInfo := newModuleInfo(*modFile)
211+
lg, _ := zap.NewDevelopment()
212+
213+
rc := RunConfig{
214+
Prune: true,
215+
Verbose: false,
216+
Logger: lg,
217+
}
218+
219+
pruneReplace("go.opentelemetry.io/build-tools/crosslink/testroot", mockModInfo, rc)
220+
221+
mockModInfo.moduleContents.Cleanup()
222+
actualReps := mockModInfo.moduleContents.Replace
223+
224+
assert.Empty(t, actualReps, "Expected all replace statements to be pruned, but %d remained", len(actualReps))
225+
}

0 commit comments

Comments
 (0)