mirror of
https://github.com/restic/restic.git
synced 2025-12-04 00:11:47 +00:00
restorer: extract hardlinks index from restic package
This commit is contained in:
33
internal/restorer/hardlinks_index_test.go
Normal file
33
internal/restorer/hardlinks_index_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package restorer_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/internal/restorer"
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
// TestHardLinks contains various tests for HardlinkIndex.
|
||||
func TestHardLinks(t *testing.T) {
|
||||
|
||||
idx := restorer.NewHardlinkIndex()
|
||||
|
||||
idx.Add(1, 2, "inode1-file1-on-device2")
|
||||
idx.Add(2, 3, "inode2-file2-on-device3")
|
||||
|
||||
sresult := idx.GetFilename(1, 2)
|
||||
rtest.Equals(t, sresult, "inode1-file1-on-device2")
|
||||
|
||||
sresult = idx.GetFilename(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)
|
||||
}
|
||||
Reference in New Issue
Block a user