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:
parent
030f08a410
commit
3a65f27c3f
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"flag"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -14,8 +13,6 @@ import (
|
|||||||
. "github.com/restic/restic/test"
|
. "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) {
|
func setupTempdir(t testing.TB) (tempdir string) {
|
||||||
tempdir, err := ioutil.TempDir(TestTempDir, "restic-test-")
|
tempdir, err := ioutil.TempDir(TestTempDir, "restic-test-")
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
@ -120,9 +117,14 @@ func TestBackup(t *testing.T) {
|
|||||||
t.Skip("integration tests disabled, use `-test.integration` to enable")
|
t.Skip("integration tests disabled, use `-test.integration` to enable")
|
||||||
}
|
}
|
||||||
|
|
||||||
if *TestDataFile == "" {
|
datafile := filepath.Join("testdata", "backup-data.tar.gz")
|
||||||
t.Fatal("no data tar file specified, use flag `-test.datafile`")
|
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)
|
tempdir := setupTempdir(t)
|
||||||
defer cleanupTempdir(t, tempdir)
|
defer cleanupTempdir(t, tempdir)
|
||||||
@ -133,7 +135,7 @@ func TestBackup(t *testing.T) {
|
|||||||
|
|
||||||
datadir := filepath.Join(tempdir, "testdata")
|
datadir := filepath.Join(tempdir, "testdata")
|
||||||
|
|
||||||
setupTarTestFixture(t, datadir, *TestDataFile)
|
setupTarTestFixture(t, datadir, datafile)
|
||||||
|
|
||||||
// first backup
|
// first backup
|
||||||
cmdBackup(t, []string{datadir}, nil)
|
cmdBackup(t, []string{datadir}, nil)
|
||||||
|
BIN
cmd/restic/testdata/backup-data.tar.gz
vendored
Normal file
BIN
cmd/restic/testdata/backup-data.tar.gz
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user