Use package "restic/test"

This commit is contained in:
Alexander Neumann
2015-04-09 21:15:48 +02:00
parent a2514425a3
commit 4f4f3c421a
24 changed files with 248 additions and 403 deletions

View File

@@ -4,6 +4,7 @@ import (
"testing"
"github.com/restic/restic/backend"
. "github.com/restic/restic/test"
)
var TestStrings = []struct {
@@ -19,24 +20,24 @@ var TestStrings = []struct {
func TestID(t *testing.T) {
for _, test := range TestStrings {
id, err := backend.ParseID(test.id)
ok(t, err)
OK(t, err)
id2, err := backend.ParseID(test.id)
ok(t, err)
assert(t, id.Equal(id2), "ID.Equal() does not work as expected")
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")
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))
OK(t, err)
Equals(t, "\""+test.id+"\"", string(buf))
var id3 backend.ID
err = id3.UnmarshalJSON(buf)
ok(t, err)
equals(t, id, id3)
OK(t, err)
Equals(t, id, id3)
}
}