check / check (push) Waiting to run
A backup under --skip-errors printed its skip errors and failed count, then "Finished successfully.", and exited 0, so a cron wrapper could not tell it from a complete backup. A directory the walk could not list was not counted at all. Each entry the walk skips is now counted as examined and failed. When anything failed under --skip-errors, the run keeps its snapshots, runs the post-backup prune as before, and then returns an error that the command reports as "Backup completed, but N file(s) failed to back up". Judgement call: without --skip-errors a file removed during the run is still counted as failed and the exit status stays 0. Model: opus-5-5
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package cli //nolint:testpackage // shares runEntry and the hermetic config helpers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestEntrySnapshotCreateSkipErrorsExitsNonZeroWhenItSkips backs up,
|
|
// under --skip-errors, a source directory that does not exist, which the
|
|
// walk skips. The command exits non-zero and reports the backup as
|
|
// completed, not as a failed snapshot creation. See
|
|
// https://git.eeqj.de/sneak/vaultik/issues/310.
|
|
//
|
|
//nolint:paralleltest // replaces os.Args, os.Stdout, os.Stderr and the xdg globals
|
|
func TestEntrySnapshotCreateSkipErrorsExitsNonZeroWhenItSkips(t *testing.T) {
|
|
// writeBackupConfig would create the source directory.
|
|
configPath := writeHermeticPruneConfig(t, false)
|
|
|
|
code, stdout, stderr := runEntry(t,
|
|
flagConfig, configPath, "--skip-errors", cmdSnapshot, cmdCreate)
|
|
|
|
assert.Equal(t, 1, code)
|
|
assert.Contains(t, stdout,
|
|
"Files: 1 examined, 0 backed up, 0 unchanged, 1 failed.")
|
|
assert.NotContains(t, stdout, "Finished successfully.")
|
|
assert.Contains(t, stderr,
|
|
"Backup completed, but 1 file(s) failed to back up")
|
|
assert.NotContains(t, stderr, "Snapshot creation failed")
|
|
}
|