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") }