1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-03-16 00:00:05 +01:00

integration test added

This commit is contained in:
jgfrm 2017-02-06 16:03:46 +01:00
parent 2995cfecc0
commit 2a568e624d
4 changed files with 47 additions and 2 deletions

View file

@ -15,6 +15,7 @@ import (
type dirEntry struct {
path string
fi os.FileInfo
link uint64
}
func walkDir(dir string) <-chan *dirEntry {
@ -32,10 +33,16 @@ func walkDir(dir string) <-chan *dirEntry {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
return nil
}
stat, err := toStatT(info.Sys())
if !err {
return nil
}
ch <- &dirEntry{
path: name,
fi: info,
link: stat.nlink(),
}
return nil

View file

@ -1011,3 +1011,42 @@ func TestPrune(t *testing.T) {
testRunCheck(t, gopts)
})
}
func TestHardLink(t *testing.T) {
withTestEnvironment(t, func(env *testEnvironment, gopts GlobalOptions) {
datafile := filepath.Join("testdata", "test.hl.tar.gz")
fd, err := os.Open(datafile)
if os.IsNotExist(errors.Cause(err)) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
testRunInit(t, gopts)
SetupTarTestFixture(t, env.testdata, datafile)
opts := BackupOptions{}
// first backup
testRunBackup(t, []string{env.testdata}, opts, gopts)
snapshotIDs := testRunList(t, "snapshots", gopts)
Assert(t, len(snapshotIDs) == 1,
"expected one snapshot, got %v", snapshotIDs)
testRunCheck(t, gopts)
stat1 := dirStats(env.repo)
// restore all backups and compare
for i, snapshotID := range snapshotIDs {
restoredir := filepath.Join(env.base, fmt.Sprintf("restore%d", i))
t.Logf("restoring snapshot %v to %v", snapshotID.Str(), restoredir)
testRunRestore(t, gopts, restoredir, snapshotIDs[0])
Assert(t, directoriesEqualContents(env.testdata, filepath.Join(restoredir, "testdata")),
"directories are not equal")
}
testRunCheck(t, gopts)
})
}

BIN
src/cmds/restic/testdata/test.hl.tar.gz vendored Normal file

Binary file not shown.

View file

@ -495,7 +495,6 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error {
node.Size = uint64(stat.size())
node.Links = uint64(stat.nlink())
case "dir":
node.Links = uint64(stat.nlink())
case "symlink":
node.LinkTarget, err = fs.Readlink(path)
node.Links = uint64(stat.nlink())