Add tests for sftp backend, split out id tests

This commit is contained in:
Alexander Neumann
2015-02-11 20:17:55 +01:00
parent 6c68150e45
commit 92e2647505
5 changed files with 91 additions and 34 deletions

32
backend/id_test.go Normal file
View File

@@ -0,0 +1,32 @@
package backend_test
import (
"testing"
"github.com/restic/restic/backend"
)
func TestID(t *testing.T) {
for _, test := range TestStrings {
id, err := backend.ParseID(test.id)
ok(t, err)
id2, err := backend.ParseID(test.id)
ok(t, err)
assert(t, id.Equal(id2), "ID.Equal() does not work as expected")
ret, err := id.EqualString(test.id)
ok(t, err)
assert(t, ret, "ID.EqualString() returned wrong value")
// test json marshalling
buf, err := id.MarshalJSON()
ok(t, err)
equals(t, "\""+test.id+"\"", string(buf))
var id3 backend.ID
err = id3.UnmarshalJSON(buf)
ok(t, err)
equals(t, id, id3)
}
}