Nothing tested that prune exits non-zero and counts partial_uploads_failed when a .partial object cannot be deleted, so dropping that branch from pruneDeleteFailures passed the suite. The new test fails every delete through faultstore and checks both. Model: opus-5-5
This commit is contained in:
1 parent
92296daf52
commit
59664f219e
1 file changed
+31
@@ -14,6 +14,7 @@ import (
|
||||
"sneak.berlin/go/vaultik/internal/config"
|
||||
"sneak.berlin/go/vaultik/internal/log"
|
||||
"sneak.berlin/go/vaultik/internal/storage"
|
||||
"sneak.berlin/go/vaultik/internal/storage/faultstore"
|
||||
"sneak.berlin/go/vaultik/internal/ui"
|
||||
"sneak.berlin/go/vaultik/internal/vaultik"
|
||||
)
|
||||
@@ -99,6 +100,36 @@ func TestPruneDeletesPartialUploadsOlderThanGracePeriod(t *testing.T) {
|
||||
assert.Equal(t, 1, result.PartialUploadsTooNew)
|
||||
}
|
||||
|
||||
// TestPruneFailedPartialUploadDeleteReturnsError checks that prune
|
||||
// returns an error, and counts the failures in the --json document, when
|
||||
// the `.partial` files it found cannot be deleted.
|
||||
func TestPruneFailedPartialUploadDeleteReturnsError(t *testing.T) {
|
||||
log.Initialize(log.Config{})
|
||||
t.Parallel()
|
||||
|
||||
v, stdout, oldFiles, _ := newPartialUploadStore(t)
|
||||
|
||||
store := faultstore.New(v.Storage)
|
||||
store.OnDelete = func(string) bool { return true }
|
||||
v.Storage = store
|
||||
|
||||
err := v.PruneBlobs(&vaultik.PruneOptions{JSON: true})
|
||||
|
||||
require.ErrorContains(t, err, "2 partial upload(s) could not be deleted")
|
||||
|
||||
for _, path := range oldFiles {
|
||||
_, statErr := os.Stat(path)
|
||||
require.NoError(t, statErr, "%s must still exist", path)
|
||||
}
|
||||
|
||||
var result vaultik.PruneBlobsResult
|
||||
|
||||
require.NoError(t, json.Unmarshal(stdout.Bytes(), &result),
|
||||
"stdout must hold the JSON document, got:\n%s", stdout.String())
|
||||
assert.Equal(t, 2, result.PartialUploadsFailed)
|
||||
assert.Equal(t, 0, result.PartialUploadsDeleted)
|
||||
}
|
||||
|
||||
// TestRemoteInfoCountsPartialUploads checks that remote info counts
|
||||
// every `.partial` file under blobs/ and metadata/, whatever its age, and
|
||||
// advises running prune.
|
||||
|
||||
Reference in new issue
Block a user