mirror of
https://github.com/restic/restic.git
synced 2026-08-18 03:23:17 +00:00
Use package "restic/test"
This commit is contained in:
+12
-11
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/restic/restic"
|
||||
"github.com/restic/restic/backend"
|
||||
. "github.com/restic/restic/test"
|
||||
)
|
||||
|
||||
var maxWorkers = flag.Uint("workers", 20, "number of workers to test Map concurrent access against")
|
||||
@@ -46,12 +47,12 @@ func TestMap(t *testing.T) {
|
||||
}
|
||||
|
||||
b2, err := bl.Find(restic.Blob{ID: b.ID, Size: b.Size})
|
||||
ok(t, err)
|
||||
assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2)
|
||||
OK(t, err)
|
||||
Assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2)
|
||||
|
||||
b2, err = bl.FindID(b.ID)
|
||||
ok(t, err)
|
||||
assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2)
|
||||
OK(t, err)
|
||||
Assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2)
|
||||
|
||||
bl2 := restic.NewMap()
|
||||
for i := 0; i < 1000; i++ {
|
||||
@@ -59,7 +60,7 @@ func TestMap(t *testing.T) {
|
||||
}
|
||||
|
||||
b2, err = bl2.Find(b)
|
||||
assert(t, err != nil, "found ID in restic that was never inserted: %v", b2)
|
||||
Assert(t, err != nil, "found ID in restic that was never inserted: %v", b2)
|
||||
|
||||
bl2.Merge(bl)
|
||||
|
||||
@@ -81,21 +82,21 @@ func TestMapJSON(t *testing.T) {
|
||||
bl.Insert(b)
|
||||
|
||||
b2, err := bl.Find(b)
|
||||
ok(t, err)
|
||||
assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2)
|
||||
OK(t, err)
|
||||
Assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2)
|
||||
|
||||
buf, err := json.Marshal(bl)
|
||||
ok(t, err)
|
||||
OK(t, err)
|
||||
|
||||
bl2 := restic.Map{}
|
||||
json.Unmarshal(buf, &bl2)
|
||||
|
||||
b2, err = bl2.Find(b)
|
||||
ok(t, err)
|
||||
assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2)
|
||||
OK(t, err)
|
||||
Assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2)
|
||||
|
||||
buf, err = json.Marshal(bl2)
|
||||
ok(t, err)
|
||||
OK(t, err)
|
||||
}
|
||||
|
||||
// random insert/find access by several goroutines
|
||||
|
||||
Reference in New Issue
Block a user