2016-08-31 17:10:10 +00:00
|
|
|
package restic
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
var handleTests = []struct {
|
|
|
|
h Handle
|
|
|
|
valid bool
|
|
|
|
}{
|
|
|
|
{Handle{Name: "foo"}, false},
|
2016-09-01 19:19:30 +00:00
|
|
|
{Handle{Type: "foobar"}, false},
|
|
|
|
{Handle{Type: ConfigFile, Name: ""}, true},
|
|
|
|
{Handle{Type: DataFile, Name: ""}, false},
|
|
|
|
{Handle{Type: "", Name: "x"}, false},
|
|
|
|
{Handle{Type: LockFile, Name: "010203040506"}, true},
|
2016-08-31 17:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestHandleValid(t *testing.T) {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|