Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion internal/api/age_retention_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ func TestSettings_AutoDeleteOldSnapshots_SweepsWhenSwitchedOn(t *testing.T) {
if _, err := ts.daemon.Store.GetSnapshot(newest[0].ID); err != nil {
t.Errorf("the branch's newest snapshot was deleted")
}
if _, err := os.Stat(filepath.Join(backups, "snap_old_auto.zip")); err == nil {
// Waited for, not looked at once: the sweep deletes the rows first and
// the archives after its last row (PruneOlderThan), so under load the row
// was found gone while the archive was still there.
if !waitFor(10*time.Second, func() bool {
_, err := os.Stat(filepath.Join(backups, "snap_old_auto.zip"))
return os.IsNotExist(err)
}) {
t.Errorf("the deleted snapshot's archive is still on disk")
}
}
Expand Down
11 changes: 8 additions & 3 deletions internal/api/savefiles_edge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"runtime"
"strconv"
"testing"
"time"
)

// A location whose folder is gone must not blank the listing. Somebody who
Expand All @@ -33,9 +34,13 @@ func TestSaveFiles_MissingLocationDoesNotBreakTheListing(t *testing.T) {
}
ts.do(t, http.MethodPost, "/api/games/gone-loc/roots", map[string]string{"name": "config", "path": cfg})

// The drive goes away.
if err := os.RemoveAll(cfg); err != nil {
t.Fatal(err)
// The drive goes away. Retried briefly: adding the location started its
// watch and first read in the background (RewatchGame), and on Windows a
// folder being read cannot be removed ("used by another process") — this
// test racing the app, as testutil.RemoveTree says of the same race.
var rmErr error
if !waitFor(5*time.Second, func() bool { rmErr = os.RemoveAll(cfg); return rmErr == nil }) {
t.Fatal(rmErr)
}

list := getSaveFiles(t, ts, "gone-loc", nil)
Expand Down
Loading