2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 23:06:32 +00:00

Automatically find fixtures for integration test

This commit is contained in:
Alexander Neumann 2015-06-13 12:40:16 +02:00
parent 030f08a410
commit 3a65f27c3f
2 changed files with 8 additions and 6 deletions

View File

@ -2,7 +2,6 @@ package main
import (
"bufio"
"flag"
"io"
"io/ioutil"
"os"
@ -14,8 +13,6 @@ import (
. "github.com/restic/restic/test"
)
var TestDataFile = flag.String("test.datafile", "", `specify tar.gz file with test data to backup and restore (required for integration test)`)
func setupTempdir(t testing.TB) (tempdir string) {
tempdir, err := ioutil.TempDir(TestTempDir, "restic-test-")
OK(t, err)
@ -120,9 +117,14 @@ func TestBackup(t *testing.T) {
t.Skip("integration tests disabled, use `-test.integration` to enable")
}
if *TestDataFile == "" {
t.Fatal("no data tar file specified, use flag `-test.datafile`")
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 TestBackup", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
tempdir := setupTempdir(t)
defer cleanupTempdir(t, tempdir)
@ -133,7 +135,7 @@ func TestBackup(t *testing.T) {
datadir := filepath.Join(tempdir, "testdata")
setupTarTestFixture(t, datadir, *TestDataFile)
setupTarTestFixture(t, datadir, datafile)
// first backup
cmdBackup(t, []string{datadir}, nil)

BIN
cmd/restic/testdata/backup-data.tar.gz vendored Normal file

Binary file not shown.