backend/rclone: Skip test if binary is unavailable

This commit is contained in:
Alexander Neumann 2018-03-14 21:14:54 +01:00
parent 4dc0f24b38
commit 065fe1e54f

View file

@ -4,11 +4,13 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/restic/restic/internal/backend/rclone" "github.com/restic/restic/internal/backend/rclone"
"github.com/restic/restic/internal/backend/test" "github.com/restic/restic/internal/backend/test"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic" "github.com/restic/restic/internal/restic"
rtest "github.com/restic/restic/internal/test" rtest "github.com/restic/restic/internal/test"
) )
@ -49,7 +51,12 @@ func newTestSuite(t testing.TB) *test.Suite {
Create: func(config interface{}) (restic.Backend, error) { Create: func(config interface{}) (restic.Backend, error) {
t.Logf("Create()") t.Logf("Create()")
cfg := config.(rclone.Config) cfg := config.(rclone.Config)
return rclone.Create(cfg) be, err := rclone.Create(cfg)
if e, ok := errors.Cause(err).(*exec.Error); ok && e.Err == exec.ErrNotFound {
t.Skipf("program %q not found", e.Name)
return nil, nil
}
return be, err
}, },
// OpenFn is a function that opens a previously created temporary repository. // OpenFn is a function that opens a previously created temporary repository.