Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(sync): restore failing tests #8

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"strings"
"syscall"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -34,6 +35,23 @@ func TestFsSyncer_Sync(t *testing.T) {
"it should copy a directory": {
fixtureSrc: "src/dir",
},
"it should copy a hard link": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test we want to test that the files a and b are hard links. But this test seems impossible to do on the CI as hard links are not supported in Git: https://stackoverflow.com/a/3731139/1351436

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",
},
Expand All @@ -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"},
},
Comment on lines +64 to +73
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are impossible using on the CI as a git clone does not keep the modification time of the files. We would love to have src/file and dst/cp-file with two different modification time. But after a git clone on the CI, both files have the same modification time. It's the time of the git clone.

"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",
Expand Down