lib/model: Add test for #5323 (#5325)

This commit is contained in:
Simon Frei 2018-11-13 09:36:16 +01:00 committed by Audrius Butkevicius
parent ba4554f053
commit db8777c29e
1 changed files with 42 additions and 0 deletions

View File

@ -686,3 +686,45 @@ func TestDiffEmpty(t *testing.T) {
}
}
}
// TestDeleteIgnorePerms checks, that a file gets deleted when the IgnorePerms
// option is true and the permissions do not match between the file on disk and
// in the db.
func TestDeleteIgnorePerms(t *testing.T) {
m := setUpModel(protocol.FileInfo{})
f := setUpSendReceiveFolder(m)
f.IgnorePerms = true
ffs := f.Filesystem()
name := "deleteIgnorePerms"
file, err := ffs.Create(name)
if err != nil {
t.Error(err)
}
defer ffs.Remove(name)
defer file.Close()
stat, err := file.Stat()
if err != nil {
t.Fatal(err)
}
fi, err := scanner.CreateFileInfo(stat, name, ffs)
if err != nil {
t.Fatal(err)
}
ffs.Chmod(name, 0600)
scanChan := make(chan string)
finished := make(chan struct{})
go func() {
err = f.checkToBeDeleted(fi, scanChan)
close(finished)
}()
select {
case <-scanChan:
<-finished
case <-finished:
}
if err != nil {
t.Fatal(err)
}
}