From b8c48a7822a6a72df86715bb6d56b47828ed120d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Michon?= Date: Mon, 27 Feb 2023 14:16:00 +0100 Subject: [PATCH] test(sync): restore failing tests --- sync_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sync_test.go b/sync_test.go index fb57a0c..98e9fac 100644 --- a/sync_test.go +++ b/sync_test.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "strings" + "syscall" "testing" "github.com/stretchr/testify/assert" @@ -34,6 +35,23 @@ func TestFsSyncer_Sync(t *testing.T) { "it should copy a directory": { fixtureSrc: "src/dir", }, + "it should copy a hard link": { + fixtureSrc: "src/hardlink", + additionalSpecs: func(t *testing.T, src, dst string) { + apath := filepath.Join(dst, "a") + bpath := filepath.Join(dst, "b") + + astat, err := os.Lstat(apath) + assert.NoError(t, err) + + bstat, err := os.Lstat(bpath) + assert.NoError(t, err) + + asysstat := astat.Sys().(*syscall.Stat_t) + bsysstat := bstat.Sys().(*syscall.Stat_t) + assert.Equal(t, asysstat.Ino, bsysstat.Ino) + }, + }, "it should copy a symlink": { fixtureSrc: "src/symlink", }, @@ -43,6 +61,16 @@ func TestFsSyncer_Sync(t *testing.T) { "it should keep the symlink to a relative path": { fixtureSrc: "src/relative-symlink", }, + "it should replace a file with the same content but not the same mtime": { + fixtureSrc: "src/file", + fixtureDst: "dst/cp-file", + expectedChanges: []string{"a"}, + }, + "it should replace a file with the same size but not the same mtime": { + fixtureSrc: "src/file", + fixtureDst: "dst/same-size", + expectedChanges: []string{"a"}, + }, "it should not replace a file with the same content but not the same mtime if checksum checks are enabled": { fixtureSrc: "src/file", fixtureDst: "dst/cp-file",