1
0
Эх сурвалжийг харах

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

Jakob Borg 11 жил өмнө
parent
commit
3e26fdfb67

+ 4 - 1
test/common_test.go

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

+ 45 - 1
test/filetype_test.go

@@ -24,9 +24,53 @@ import (
 	"strings"
 	"testing"
 	"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...")
 	err := removeAll("s1", "s2", "h1/index", "h2/index")
 	if err != nil {

+ 44 - 1
test/symlink_test.go

@@ -24,10 +24,53 @@ import (
 	"testing"
 	"time"
 
+	"github.com/syncthing/syncthing/internal/config"
+	"github.com/syncthing/syncthing/internal/protocol"
 	"github.com/syncthing/syncthing/internal/symlinks"
 )
 
 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...")
 	err := removeAll("s1", "s2", "h1/index", "h2/index")
 	if err != nil {
@@ -236,7 +279,7 @@ func TestSymlinks(t *testing.T) {
 		log.Fatal(err)
 	}
 
-	// Remove a symlink
+	// Remove a broken symlink
 
 	err = os.Remove("s1/removeLink")
 	if err != nil {