2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-06 11:00:48 +00:00

backend/test: Randomize test suite

This commit is contained in:
Alexander Neumann 2017-05-28 10:16:29 +02:00
parent 7ec0543af3
commit 79477fdfe4

View File

@ -13,12 +13,19 @@ import (
"sort"
"strings"
"testing"
"time"
"restic/test"
"restic/backend"
)
func seedRand(t testing.TB) {
seed := time.Now().UnixNano()
rand.Seed(seed)
t.Logf("rand initialized with seed %d", seed)
}
// TestCreateWithConfig tests that creating a backend in a location which already
// has a config file fails.
func (s *Suite) TestCreateWithConfig(t *testing.T) {
@ -101,6 +108,8 @@ func (s *Suite) TestConfig(t *testing.T) {
// TestLoad tests the backend's Load function.
func (s *Suite) TestLoad(t *testing.T) {
seedRand(t)
b := s.open(t)
defer s.close(t, b)
@ -160,6 +169,7 @@ func (s *Suite) TestLoad(t *testing.T) {
d = d[:l]
}
t.Logf("Load, l %v, o %v, len(d) %v, getlen %v", l, o, len(d), getlen)
rd, err := b.Load(handle, getlen, int64(o))
if err != nil {
t.Errorf("Load(%d, %d) returned unexpected error: %+v", l, o, err)
@ -234,6 +244,8 @@ func (ec errorCloser) Size() int64 {
// TestSave tests saving data in the backend.
func (s *Suite) TestSave(t *testing.T) {
seedRand(t)
b := s.open(t)
defer s.close(t, b)
var id restic.ID