From 43d4558a90c5f14b88b25bdc16dc01f985a82fe6 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 21 Jun 2015 15:32:26 +0200 Subject: [PATCH] Add test for backing up non-existing directories --- cmd/restic/integration_test.go | 29 ++++++++++++++++++++++ testsuite/test-backup-non-existing-file.sh | 10 -------- 2 files changed, 29 insertions(+), 10 deletions(-) delete mode 100755 testsuite/test-backup-non-existing-file.sh diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index 22e00ded5..62d972b97 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -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 diff --git a/testsuite/test-backup-non-existing-file.sh b/testsuite/test-backup-non-existing-file.sh deleted file mode 100755 index d06fe5c8e..000000000 --- a/testsuite/test-backup-non-existing-file.sh +++ /dev/null @@ -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