2
2
mirror of https://github.com/octoleo/restic.git synced 2024-09-27 22:19:02 +00:00
restic/internal/restic/hardlinks_index_test.go

36 lines
725 B
Go
Raw Normal View History

2017-01-30 23:14:20 +00:00
package restic_test
import (
"testing"
2017-07-24 15:42:25 +00:00
"github.com/restic/restic/internal/restic"
2017-07-23 12:21:03 +00:00
. "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) {
idx := restic.NewHardlinkIndex()
idx.Add(1, 2, "inode1-file1-on-device2")
idx.Add(2, 3, "inode2-file2-on-device3")
var sresult string
sresult = idx.GetFilename(1, 2)
Equals(t, sresult, "inode1-file1-on-device2")
sresult = idx.GetFilename(2, 3)
Equals(t, sresult, "inode2-file2-on-device3")
var bresult bool
bresult = idx.Has(1, 2)
Equals(t, bresult, true)
bresult = idx.Has(1, 3)
Equals(t, bresult, false)
idx.Remove(1, 2)
bresult = idx.Has(1, 2)
Equals(t, bresult, false)
}