mirror of https://github.com/restic/restic.git
Make test files in test repo less random
This commit is contained in:
parent
d9012b4a64
commit
b55ac2afd6
|
@ -21,6 +21,7 @@ func fakeFile(t testing.TB, seed, size int64) io.Reader {
|
||||||
// saveFile reads from rd and saves the blobs in the repository. The list of
|
// saveFile reads from rd and saves the blobs in the repository. The list of
|
||||||
// IDs is returned.
|
// IDs is returned.
|
||||||
func saveFile(t testing.TB, repo *repository.Repository, rd io.Reader) (blobs backend.IDs) {
|
func saveFile(t testing.TB, repo *repository.Repository, rd io.Reader) (blobs backend.IDs) {
|
||||||
|
blobs = backend.IDs{}
|
||||||
ch := chunker.New(rd, repo.Config.ChunkerPolynomial)
|
ch := chunker.New(rd, repo.Config.ChunkerPolynomial)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -30,7 +31,7 @@ func saveFile(t testing.TB, repo *repository.Repository, rd io.Reader) (blobs ba
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unabel to save chunk in repo: %v", err)
|
t.Fatalf("unable to save chunk in repo: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := repo.SaveAndEncrypt(pack.Data, chunk.Data, nil)
|
id, err := repo.SaveAndEncrypt(pack.Data, chunk.Data, nil)
|
||||||
|
@ -45,7 +46,7 @@ func saveFile(t testing.TB, repo *repository.Repository, rd io.Reader) (blobs ba
|
||||||
|
|
||||||
const (
|
const (
|
||||||
maxFileSize = 1500000
|
maxFileSize = 1500000
|
||||||
maxSeed = 20
|
maxSeed = 32
|
||||||
maxNodes = 32
|
maxNodes = 32
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ func saveTree(t testing.TB, repo *repository.Repository, seed int64, depth int)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSeed := rnd.Int63() % maxSeed
|
fileSeed := rnd.Int63() % maxSeed
|
||||||
fileSize := rnd.Int63() % maxFileSize
|
fileSize := (maxFileSize / maxSeed) * fileSeed
|
||||||
|
|
||||||
node := &Node{
|
node := &Node{
|
||||||
Name: fmt.Sprintf("file-%v", fileSeed),
|
Name: fmt.Sprintf("file-%v", fileSeed),
|
||||||
|
|
Loading…
Reference in New Issue