2022-07-17 11:45:42 +00:00
|
|
|
package restorer_test
|
2017-01-30 23:14:20 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-07-17 11:45:42 +00:00
|
|
|
"github.com/restic/restic/internal/restorer"
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest "github.com/restic/restic/internal/test"
|
2017-01-30 23:14:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// TestHardLinks contains various tests for HardlinkIndex.
|
|
|
|
func TestHardLinks(t *testing.T) {
|
|
|
|
|
2023-10-01 21:24:42 +00:00
|
|
|
idx := restorer.NewHardlinkIndex[string]()
|
2017-01-30 23:14:20 +00:00
|
|
|
|
|
|
|
idx.Add(1, 2, "inode1-file1-on-device2")
|
|
|
|
idx.Add(2, 3, "inode2-file2-on-device3")
|
|
|
|
|
2023-10-01 21:24:42 +00:00
|
|
|
sresult := idx.Value(1, 2)
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest.Equals(t, sresult, "inode1-file1-on-device2")
|
2017-01-30 23:14:20 +00:00
|
|
|
|
2023-10-01 21:24:42 +00:00
|
|
|
sresult = idx.Value(2, 3)
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest.Equals(t, sresult, "inode2-file2-on-device3")
|
2017-01-30 23:14:20 +00:00
|
|
|
|
2020-03-06 22:27:37 +00:00
|
|
|
bresult := idx.Has(1, 2)
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest.Equals(t, bresult, true)
|
2017-01-30 23:14:20 +00:00
|
|
|
|
|
|
|
bresult = idx.Has(1, 3)
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest.Equals(t, bresult, false)
|
2017-01-30 23:14:20 +00:00
|
|
|
|
|
|
|
idx.Remove(1, 2)
|
|
|
|
bresult = idx.Has(1, 2)
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest.Equals(t, bresult, false)
|
2017-01-30 23:14:20 +00:00
|
|
|
}
|