restic/internal/restic/blob_set_test.go
greatroar 691c01963b internal/restic: Return summary from BlobSet.String
Fixes #4449: error messages from prune were too long to fit in scroll
buffers.
2023-08-25 21:41:30 +02:00

32 lines
678 B
Go

package restic
import (
"math/rand"
"regexp"
"testing"
rtest "github.com/restic/restic/internal/test"
)
func TestBlobSetString(t *testing.T) {
s := NewBlobSet()
rtest.Equals(t, "{}", s.String())
id, _ := ParseID(
"1111111111111111111111111111111111111111111111111111111111111111")
s.Insert(BlobHandle{ID: id, Type: TreeBlob})
rtest.Equals(t, "{<tree/11111111>}", s.String())
var h BlobHandle
for i := 0; i < 100; i++ {
h.Type = DataBlob
_, _ = rand.Read(h.ID[:])
s.Insert(h)
}
r := regexp.MustCompile(
`^{(?:<(?:data|tree)/[0-9a-f]{8}> ){10}\(90 more\)}$`)
str := s.String()
rtest.Assert(t, r.MatchString(str), "%q doesn't match pattern", str)
}