github.com/mckael/restic@v0.8.3/internal/restic/hardlinks_index_test.go (about) 1 package restic_test 2 3 import ( 4 "testing" 5 6 "github.com/restic/restic/internal/restic" 7 rtest "github.com/restic/restic/internal/test" 8 ) 9 10 // TestHardLinks contains various tests for HardlinkIndex. 11 func TestHardLinks(t *testing.T) { 12 13 idx := restic.NewHardlinkIndex() 14 15 idx.Add(1, 2, "inode1-file1-on-device2") 16 idx.Add(2, 3, "inode2-file2-on-device3") 17 18 var sresult string 19 sresult = idx.GetFilename(1, 2) 20 rtest.Equals(t, sresult, "inode1-file1-on-device2") 21 22 sresult = idx.GetFilename(2, 3) 23 rtest.Equals(t, sresult, "inode2-file2-on-device3") 24 25 var bresult bool 26 bresult = idx.Has(1, 2) 27 rtest.Equals(t, bresult, true) 28 29 bresult = idx.Has(1, 3) 30 rtest.Equals(t, bresult, false) 31 32 idx.Remove(1, 2) 33 bresult = idx.Has(1, 2) 34 rtest.Equals(t, bresult, false) 35 }