mirror of
https://github.com/restic/restic.git
synced 2026-06-21 16:14:18 +00:00
c062a78dcd
This removes them from the public interface. The latter now only provides the PackBlob interface, without being bound to the type used internally by the pack package.
41 lines
1003 B
Go
41 lines
1003 B
Go
package index
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/restic/restic/internal/repository/pack"
|
|
"github.com/restic/restic/internal/restic"
|
|
rtest "github.com/restic/restic/internal/test"
|
|
)
|
|
|
|
func TestIndexOversized(t *testing.T) {
|
|
idx := NewIndex()
|
|
|
|
// Add blobs up to indexMaxBlobs + pack.MaxHeaderEntries - 1
|
|
packID := idx.addToPacks(restic.NewRandomID())
|
|
for i := uint(0); i < indexMaxBlobs+pack.MaxHeaderEntries-1; i++ {
|
|
idx.store(packID, pack.Blob{
|
|
BlobHandle: restic.BlobHandle{
|
|
Type: restic.DataBlob,
|
|
ID: restic.NewRandomID(),
|
|
},
|
|
Length: 100,
|
|
Offset: uint(i) * 100,
|
|
})
|
|
}
|
|
|
|
rtest.Assert(t, !Oversized(idx), "index should not be considered oversized")
|
|
|
|
// Add one more blob to exceed the limit
|
|
idx.store(packID, pack.Blob{
|
|
BlobHandle: restic.BlobHandle{
|
|
Type: restic.DataBlob,
|
|
ID: restic.NewRandomID(),
|
|
},
|
|
Length: 100,
|
|
Offset: uint(indexMaxBlobs+pack.MaxHeaderEntries) * 100,
|
|
})
|
|
|
|
rtest.Assert(t, Oversized(idx), "index should be considered oversized")
|
|
}
|