Files
restic/internal/data/hardlinks_index_test.go
T
Michael Eischer 5cd39d01c1 internal/data: extract HardlinkIndex from restorer
The HardlinkIndex is also used by `cmd_stats`, thus place it in a shared
package.
2026-06-20 17:49:20 +02:00

34 lines
713 B
Go

package data_test
import (
"testing"
"github.com/restic/restic/internal/data"
rtest "github.com/restic/restic/internal/test"
)
// TestHardLinks contains various tests for HardlinkIndex.
func TestHardLinks(t *testing.T) {
idx := data.NewHardlinkIndex[string]()
idx.Add(1, 2, "inode1-file1-on-device2")
idx.Add(2, 3, "inode2-file2-on-device3")
sresult := idx.Value(1, 2)
rtest.Equals(t, sresult, "inode1-file1-on-device2")
sresult = idx.Value(2, 3)
rtest.Equals(t, sresult, "inode2-file2-on-device3")
bresult := idx.Has(1, 2)
rtest.Equals(t, bresult, true)
bresult = idx.Has(1, 3)
rtest.Equals(t, bresult, false)
idx.Remove(1, 2)
bresult = idx.Has(1, 2)
rtest.Equals(t, bresult, false)
}