Run filetype and symlink integration tests with versioning (ref #1071)

This commit is contained in:
Jakob Borg 2014-12-03 11:03:44 +01:00
parent e1be73232d
commit 3e26fdfb67
3 changed files with 93 additions and 3 deletions

View File

@ -379,9 +379,12 @@ func startWalker(dir string, res chan<- fileInfo, abort <-chan struct{}) {
if rn == "." || rn == ".stfolder" { if rn == "." || rn == ".stfolder" {
return nil return nil
} }
if rn == ".stversions" {
return filepath.SkipDir
}
var f fileInfo var f fileInfo
if ok, err := symlinks.IsSymlink(path); err == nil && ok { if info.Mode()&os.ModeSymlink != 0 {
f = fileInfo{ f = fileInfo{
name: rn, name: rn,
mode: os.ModeSymlink, mode: os.ModeSymlink,

View File

@ -24,9 +24,53 @@ import (
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/syncthing/syncthing/internal/config"
"github.com/syncthing/syncthing/internal/protocol"
) )
func TestFiletypeChange(t *testing.T) { func TestFileTypeChange(t *testing.T) {
// Use no versioning
id, _ := protocol.DeviceIDFromString(id2)
cfg, _ := config.Load("h2/config.xml", id)
fld := cfg.Folders()["default"]
fld.Versioning = config.VersioningConfiguration{}
cfg.SetFolder(fld)
cfg.Save()
testFileTypeChange(t)
}
func TestFileTypeChangeSimpleVersioning(t *testing.T) {
// Use simple versioning
id, _ := protocol.DeviceIDFromString(id2)
cfg, _ := config.Load("h2/config.xml", id)
fld := cfg.Folders()["default"]
fld.Versioning = config.VersioningConfiguration{
Type: "simple",
Params: map[string]string{"keep": "5"},
}
cfg.SetFolder(fld)
cfg.Save()
testFileTypeChange(t)
}
func TestFileTypeChangeStaggeredVersioning(t *testing.T) {
// Use staggered versioning
id, _ := protocol.DeviceIDFromString(id2)
cfg, _ := config.Load("h2/config.xml", id)
fld := cfg.Folders()["default"]
fld.Versioning = config.VersioningConfiguration{
Type: "staggered",
}
cfg.SetFolder(fld)
cfg.Save()
testFileTypeChange(t)
}
func testFileTypeChange(t *testing.T) {
log.Println("Cleaning...") log.Println("Cleaning...")
err := removeAll("s1", "s2", "h1/index", "h2/index") err := removeAll("s1", "s2", "h1/index", "h2/index")
if err != nil { if err != nil {

View File

@ -24,10 +24,53 @@ import (
"testing" "testing"
"time" "time"
"github.com/syncthing/syncthing/internal/config"
"github.com/syncthing/syncthing/internal/protocol"
"github.com/syncthing/syncthing/internal/symlinks" "github.com/syncthing/syncthing/internal/symlinks"
) )
func TestSymlinks(t *testing.T) { func TestSymlinks(t *testing.T) {
// Use no versioning
id, _ := protocol.DeviceIDFromString(id2)
cfg, _ := config.Load("h2/config.xml", id)
fld := cfg.Folders()["default"]
fld.Versioning = config.VersioningConfiguration{}
cfg.SetFolder(fld)
cfg.Save()
testSymlinks(t)
}
func TestSymlinksSimpleVersioning(t *testing.T) {
// Use no versioning
id, _ := protocol.DeviceIDFromString(id2)
cfg, _ := config.Load("h2/config.xml", id)
fld := cfg.Folders()["default"]
fld.Versioning = config.VersioningConfiguration{
Type: "simple",
Params: map[string]string{"keep": "5"},
}
cfg.SetFolder(fld)
cfg.Save()
testSymlinks(t)
}
func TestSymlinksStaggeredVersioning(t *testing.T) {
// Use no versioning
id, _ := protocol.DeviceIDFromString(id2)
cfg, _ := config.Load("h2/config.xml", id)
fld := cfg.Folders()["default"]
fld.Versioning = config.VersioningConfiguration{
Type: "staggered",
}
cfg.SetFolder(fld)
cfg.Save()
testSymlinks(t)
}
func testSymlinks(t *testing.T) {
log.Println("Cleaning...") log.Println("Cleaning...")
err := removeAll("s1", "s2", "h1/index", "h2/index") err := removeAll("s1", "s2", "h1/index", "h2/index")
if err != nil { if err != nil {
@ -236,7 +279,7 @@ func TestSymlinks(t *testing.T) {
log.Fatal(err) log.Fatal(err)
} }
// Remove a symlink // Remove a broken symlink
err = os.Remove("s1/removeLink") err = os.Remove("s1/removeLink")
if err != nil { if err != nil {