archiver: Clarify value in test struct

Since I could not remember what the value for `Check` means this commit
renames it to `SameFile`: when set to true, the test should make sure
that `FileChanged` should return false (=file is unmodified).
This commit is contained in:
Alexander Neumann 2019-05-05 12:50:47 +02:00
parent 7dcd2968b6
commit 303a5dab6a

View file

@ -560,7 +560,7 @@ func TestFileChanged(t *testing.T) {
Content []byte
Modify func(t testing.TB, filename string)
IgnoreInode bool
Check bool
SameFile bool
}{
{
Name: "same-content-new-file",
@ -622,7 +622,7 @@ func TestFileChanged(t *testing.T) {
setTimestamp(t, filename, fi.ModTime(), fi.ModTime())
},
IgnoreInode: true,
Check: true,
SameFile: true,
},
}
@ -648,10 +648,15 @@ func TestFileChanged(t *testing.T) {
test.Modify(t, filename)
fiAfter := lstat(t, filename)
if test.Check == fileChanged(fiAfter, node, test.IgnoreInode) {
if test.Check {
if test.SameFile {
// file should be detected as unchanged
if fileChanged(fiAfter, node, test.IgnoreInode) {
t.Fatalf("unmodified file detected as changed")
} else {
}
} else {
// file should be detected as changed
if !fileChanged(fiAfter, node, test.IgnoreInode) && !test.SameFile {
t.Fatalf("modified file detected as unchanged")
}
}