The --prune flag on 'snapshot create' was accepted but silently did nothing (TODO stub). This connects it to actually: 1. Purge old snapshots (keeping only the latest) via PurgeSnapshots 2. Remove unreferenced blobs from storage via PruneBlobs The pruning runs after all snapshots complete successfully, not per-snapshot. Both operations use --force mode (no interactive confirmation) since --prune is an explicit opt-in flag. Moved the prune logic from createNamedSnapshot (per-snapshot) to CreateSnapshot (after all snapshots), which is the correct location.
24 lines
440 B
Go
24 lines
440 B
Go
package vaultik
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// TestSnapshotCreateOptions_PruneFlag verifies the Prune field exists on
|
|
// SnapshotCreateOptions and can be set.
|
|
func TestSnapshotCreateOptions_PruneFlag(t *testing.T) {
|
|
opts := &SnapshotCreateOptions{
|
|
Prune: true,
|
|
}
|
|
if !opts.Prune {
|
|
t.Error("Expected Prune to be true")
|
|
}
|
|
|
|
opts2 := &SnapshotCreateOptions{
|
|
Prune: false,
|
|
}
|
|
if opts2.Prune {
|
|
t.Error("Expected Prune to be false")
|
|
}
|
|
}
|