mirror of https://github.com/restic/restic.git
Remove more flags from tests
This commit is contained in:
parent
0ad08b2f70
commit
9853fbcf48
|
@ -1,22 +1,37 @@
|
|||
package backend_test
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/backend/sftp"
|
||||
. "github.com/restic/restic/test"
|
||||
)
|
||||
|
||||
var sftpPath = flag.String("test.sftppath", "", "sftp binary path (default: empty)")
|
||||
|
||||
func setupSFTPBackend(t *testing.T) *sftp.SFTP {
|
||||
sftpserver := ""
|
||||
|
||||
for _, dir := range strings.Split(TestSFTPPath, ":") {
|
||||
testpath := filepath.Join(dir, "sftp-server")
|
||||
fd, err := os.Open(testpath)
|
||||
fd.Close()
|
||||
if !os.IsNotExist(err) {
|
||||
sftpserver = testpath
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if sftpserver == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
tempdir, err := ioutil.TempDir("", "restic-test-")
|
||||
OK(t, err)
|
||||
|
||||
b, err := sftp.Create(tempdir, *sftpPath)
|
||||
b, err := sftp.Create(tempdir, sftpserver)
|
||||
OK(t, err)
|
||||
|
||||
t.Logf("created sftp backend locally at %s", tempdir)
|
||||
|
@ -36,14 +51,14 @@ func teardownSFTPBackend(t *testing.T, b *sftp.SFTP) {
|
|||
|
||||
func TestSFTPBackend(t *testing.T) {
|
||||
if !RunIntegrationTest {
|
||||
t.Skip("integration tests disabled, use `-test.integration` to enable")
|
||||
}
|
||||
|
||||
if *sftpPath == "" {
|
||||
t.Skipf("sftppath not set, skipping TestSFTPBackend")
|
||||
t.Skip("integration tests disabled")
|
||||
}
|
||||
|
||||
s := setupSFTPBackend(t)
|
||||
if s == nil {
|
||||
t.Skip("unable to find sftp-server binary")
|
||||
return
|
||||
}
|
||||
defer teardownSFTPBackend(t, s)
|
||||
|
||||
testBackend(s, t)
|
||||
|
|
|
@ -114,7 +114,7 @@ func cmdFsck(t testing.TB) {
|
|||
|
||||
func TestBackup(t *testing.T) {
|
||||
if !RunIntegrationTest {
|
||||
t.Skip("integration tests disabled, use `-test.integration` to enable")
|
||||
t.Skip("integration tests disabled")
|
||||
}
|
||||
|
||||
datafile := filepath.Join("testdata", "backup-data.tar.gz")
|
||||
|
|
|
@ -18,6 +18,8 @@ var (
|
|||
TestCleanup = getBoolVar("RESTIC_TEST_CLEANUP", true)
|
||||
TestTempDir = getStringVar("RESTIC_TEST_TMPDIR", "")
|
||||
RunIntegrationTest = getBoolVar("RESTIC_TEST_INTEGRATION", true)
|
||||
TestSFTPPath = getStringVar("RESTIC_TEST_SFTPPATH",
|
||||
"/usr/lib/ssh:/usr/lib/openssh")
|
||||
)
|
||||
|
||||
func getStringVar(name, defaultValue string) string {
|
||||
|
|
Loading…
Reference in New Issue