fix(worktree): TestAwaitSpace recovery rows get a deadline a loaded host cannot run out

This commit is contained in:
sam committed 2026-11-09 14:27:18 +11:00
1 parent 4b0adac674
commit ec79c8123e
1 file changed
+7 -4
+7 -4
View File
@@ -11,11 +11,14 @@ func TestAwaitSpace(t *testing.T) {
tests := []struct {
name string
reports []uint64
// wait is generous where the space recovers, so a loaded host
// cannot run out the deadline before the fake's later reports.
wait time.Duration
wantErr error
}{
{"enough at once", []uint64{10}, nil},
{"low then recovers", []uint64{1, 1, 10}, nil},
{"stays low", []uint64{1}, ErrDiskLow},
{"enough at once", []uint64{10}, 5 * time.Second, nil},
{"low then recovers", []uint64{1, 1, 10}, 5 * time.Second, nil},
{"stays low", []uint64{1}, 20 * time.Millisecond, ErrDiskLow},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -25,7 +28,7 @@ func TestAwaitSpace(t *testing.T) {
calls++
return tt.reports[i], nil
}
err := AwaitSpace(context.Background(), free, 5, time.Millisecond, 20*time.Millisecond)
err := AwaitSpace(context.Background(), free, 5, time.Millisecond, tt.wait)
if !errors.Is(err, tt.wantErr) {
t.Fatalf("err = %v, want %v", err, tt.wantErr)
}