mirror of
https://github.com/restic/restic.git
synced 2024-12-24 08:44:52 +00:00
Add test for backing up non-existing directories
This commit is contained in:
parent
675f341b6d
commit
43d4558a90
2 changed files with 29 additions and 10 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"crypto/rand"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
@ -146,6 +147,34 @@ func TestBackup(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestBackupNonExistingFile(t *testing.T) {
|
||||
withTestEnvironment(t, func(env *testEnvironment, global GlobalOptions) {
|
||||
datafile := filepath.Join("testdata", "backup-data.tar.gz")
|
||||
fd, err := os.Open(datafile)
|
||||
if os.IsNotExist(err) {
|
||||
t.Skipf("unable to find data file %q, skipping", datafile)
|
||||
return
|
||||
}
|
||||
OK(t, err)
|
||||
OK(t, fd.Close())
|
||||
|
||||
setupTarTestFixture(t, env.testdata, datafile)
|
||||
|
||||
cmdInit(t, global)
|
||||
|
||||
global.stderr = ioutil.Discard
|
||||
|
||||
p := filepath.Join(env.testdata, "0", "0")
|
||||
dirs := []string{
|
||||
filepath.Join(p, "0"),
|
||||
filepath.Join(p, "1"),
|
||||
filepath.Join(p, "nonexisting"),
|
||||
filepath.Join(p, "5"),
|
||||
}
|
||||
cmdBackup(t, global, dirs, nil)
|
||||
})
|
||||
}
|
||||
|
||||
const (
|
||||
incrementalFirstWrite = 20 * 1042 * 1024
|
||||
incrementalSecondWrite = 12 * 1042 * 1024
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
set -em
|
||||
|
||||
# setup restic
|
||||
prepare
|
||||
run restic init
|
||||
|
||||
# start backup with non existing dir
|
||||
run timeout 10s restic.debug backup "${BASE}/fake-data/0/0/"{0,1,foobar,5} && debug "done" || false
|
||||
|
||||
cleanup
|
Loading…
Reference in a new issue