move Backend interface to backend package
This commit is contained in:
parent
ceb0774af1
commit
1b8a67fe76
105 changed files with 822 additions and 775 deletions
36
internal/backend/file_test.go
Normal file
36
internal/backend/file_test.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package backend
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
func TestHandleString(t *testing.T) {
|
||||
rtest.Equals(t, "<data/foobar>", Handle{Type: PackFile, Name: "foobar"}.String())
|
||||
rtest.Equals(t, "<lock/1>", Handle{Type: LockFile, Name: "1"}.String())
|
||||
}
|
||||
|
||||
func TestHandleValid(t *testing.T) {
|
||||
var handleTests = []struct {
|
||||
h Handle
|
||||
valid bool
|
||||
}{
|
||||
{Handle{Name: "foo"}, false},
|
||||
{Handle{Type: 0}, false},
|
||||
{Handle{Type: ConfigFile, Name: ""}, true},
|
||||
{Handle{Type: PackFile, Name: ""}, false},
|
||||
{Handle{Type: LockFile, Name: "010203040506"}, true},
|
||||
}
|
||||
|
||||
for i, test := range handleTests {
|
||||
err := test.h.Valid()
|
||||
if err != nil && test.valid {
|
||||
t.Errorf("test %v failed: error returned for valid handle: %v", i, err)
|
||||
}
|
||||
|
||||
if !test.valid && err == nil {
|
||||
t.Errorf("test %v failed: expected error for invalid handle not found", i)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue