mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
parent
470ef87dd5
commit
55a7830ff9
@ -40,6 +40,7 @@ func TestMain(m *testing.M) {
|
|||||||
backendBuffer = 10
|
backendBuffer = 10
|
||||||
defer func() {
|
defer func() {
|
||||||
backendBuffer = 500
|
backendBuffer = 500
|
||||||
|
os.RemoveAll(testDir)
|
||||||
}()
|
}()
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
2
lib/model/.gitignore
vendored
2
lib/model/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
.stfolder
|
|
||||||
.stignore
|
|
@ -36,10 +36,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var device1, device2 protocol.DeviceID
|
var device1, device2 protocol.DeviceID
|
||||||
var defaultConfig *config.Wrapper
|
var defaultCfgWrapper *config.Wrapper
|
||||||
var defaultFolderConfig config.FolderConfiguration
|
var defaultFolderConfig config.FolderConfiguration
|
||||||
var defaultFs fs.Filesystem
|
var defaultFs fs.Filesystem
|
||||||
|
var defaultCfg config.Configuration
|
||||||
var defaultAutoAcceptCfg config.Configuration
|
var defaultAutoAcceptCfg config.Configuration
|
||||||
|
var tmpLocation string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
device1, _ = protocol.DeviceIDFromString("AIR6LPZ-7K4PTTV-UXQSMUU-CPQ5YWH-OEDFIIQ-JUG777G-2YQXXR5-YD6AWQR")
|
device1, _ = protocol.DeviceIDFromString("AIR6LPZ-7K4PTTV-UXQSMUU-CPQ5YWH-OEDFIIQ-JUG777G-2YQXXR5-YD6AWQR")
|
||||||
@ -48,7 +50,7 @@ func init() {
|
|||||||
|
|
||||||
defaultFolderConfig = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, "testdata")
|
defaultFolderConfig = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, "testdata")
|
||||||
defaultFolderConfig.Devices = []config.FolderDeviceConfiguration{{DeviceID: device1}}
|
defaultFolderConfig.Devices = []config.FolderDeviceConfiguration{{DeviceID: device1}}
|
||||||
_defaultConfig := config.Configuration{
|
defaultCfg = config.Configuration{
|
||||||
Version: config.CurrentVersion,
|
Version: config.CurrentVersion,
|
||||||
Folders: []config.FolderConfiguration{defaultFolderConfig},
|
Folders: []config.FolderConfiguration{defaultFolderConfig},
|
||||||
Devices: []config.DeviceConfiguration{config.NewDeviceConfiguration(device1, "device1")},
|
Devices: []config.DeviceConfiguration{config.NewDeviceConfiguration(device1, "device1")},
|
||||||
@ -57,7 +59,6 @@ func init() {
|
|||||||
KeepTemporariesH: 1,
|
KeepTemporariesH: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
defaultConfig = config.Wrap("/tmp/test", _defaultConfig)
|
|
||||||
defaultAutoAcceptCfg = config.Configuration{
|
defaultAutoAcceptCfg = config.Configuration{
|
||||||
Devices: []config.DeviceConfiguration{
|
Devices: []config.DeviceConfiguration{
|
||||||
{
|
{
|
||||||
@ -106,10 +107,52 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
tmpLocation = "/tmp"
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
tmpLocation = filepath.Join("testdata", "tmp")
|
||||||
|
if err := os.MkdirAll(tmpLocation, 0777); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpName := fs.TempName("file")
|
||||||
|
if err := osutil.Copy(defaultFs, "tmpfile", tmpName); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
future := time.Now().Add(time.Hour)
|
||||||
|
if err := os.Chtimes(filepath.Join("testdata", tmpName), future, future); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var wrapperPath string
|
||||||
|
defaultCfgWrapper, wrapperPath = createTmpWrapper(defaultCfg)
|
||||||
|
|
||||||
|
exitCode := m.Run()
|
||||||
|
|
||||||
|
os.Remove(wrapperPath)
|
||||||
|
defaultFs.Remove(tmpName)
|
||||||
|
defaultFs.RemoveAll(config.DefaultMarkerName)
|
||||||
|
defaultFs.RemoveAll(tmpLocation)
|
||||||
|
|
||||||
|
os.Exit(exitCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTmpWrapper(cfg config.Configuration) (*config.Wrapper, string) {
|
||||||
|
tmpFile, err := ioutil.TempFile(tmpLocation, "syncthing-testConfig-")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
wrapper := config.Wrap(tmpFile.Name(), cfg)
|
||||||
|
tmpFile.Close()
|
||||||
|
return wrapper, tmpFile.Name()
|
||||||
|
}
|
||||||
|
|
||||||
func newState(cfg config.Configuration) (*config.Wrapper, *Model) {
|
func newState(cfg config.Configuration) (*config.Wrapper, *Model) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
|
|
||||||
wcfg := config.Wrap("/tmp/test", cfg)
|
wcfg, path := createTmpWrapper(cfg)
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
m := NewModel(wcfg, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(wcfg, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
for _, folder := range cfg.Folders {
|
for _, folder := range cfg.Folders {
|
||||||
@ -125,7 +168,7 @@ func newState(cfg config.Configuration) (*config.Wrapper, *Model) {
|
|||||||
func TestRequest(t *testing.T) {
|
func TestRequest(t *testing.T) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
|
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
|
|
||||||
// device1 shares default, but device2 doesn't
|
// device1 shares default, but device2 doesn't
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
@ -204,7 +247,7 @@ func BenchmarkIndex_100(b *testing.B) {
|
|||||||
|
|
||||||
func benchmarkIndex(b *testing.B, nfiles int) {
|
func benchmarkIndex(b *testing.B, nfiles int) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -234,7 +277,7 @@ func BenchmarkIndexUpdate_10000_1(b *testing.B) {
|
|||||||
|
|
||||||
func benchmarkIndexUpdate(b *testing.B, nfiles, nufiles int) {
|
func benchmarkIndexUpdate(b *testing.B, nfiles, nufiles int) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -422,7 +465,7 @@ func (f *fakeConnection) sendIndexUpdate() {
|
|||||||
|
|
||||||
func BenchmarkRequestOut(b *testing.B) {
|
func BenchmarkRequestOut(b *testing.B) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
defer m.Stop()
|
defer m.Stop()
|
||||||
@ -452,7 +495,7 @@ func BenchmarkRequestOut(b *testing.B) {
|
|||||||
|
|
||||||
func BenchmarkRequestInSingleFile(b *testing.B) {
|
func BenchmarkRequestInSingleFile(b *testing.B) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
defer m.Stop()
|
defer m.Stop()
|
||||||
@ -481,7 +524,7 @@ func TestDeviceRename(t *testing.T) {
|
|||||||
ClientName: "syncthing",
|
ClientName: "syncthing",
|
||||||
ClientVersion: "v0.9.4",
|
ClientVersion: "v0.9.4",
|
||||||
}
|
}
|
||||||
defer os.Remove("tmpconfig.xml")
|
defer os.Remove("testdata/tmpconfig.xml")
|
||||||
|
|
||||||
rawCfg := config.New(device1)
|
rawCfg := config.New(device1)
|
||||||
rawCfg.Devices = []config.DeviceConfiguration{
|
rawCfg.Devices = []config.DeviceConfiguration{
|
||||||
@ -489,7 +532,7 @@ func TestDeviceRename(t *testing.T) {
|
|||||||
DeviceID: device1,
|
DeviceID: device1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cfg := config.Wrap("tmpconfig.xml", rawCfg)
|
cfg := config.Wrap("testdata/tmpconfig.xml", rawCfg)
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(cfg, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(cfg, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
@ -525,7 +568,7 @@ func TestDeviceRename(t *testing.T) {
|
|||||||
t.Errorf("Device name got overwritten")
|
t.Errorf("Device name got overwritten")
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgw, err := config.Load("tmpconfig.xml", protocol.LocalDeviceID)
|
cfgw, err := config.Load("testdata/tmpconfig.xml", protocol.LocalDeviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
@ -580,7 +623,9 @@ func TestClusterConfig(t *testing.T) {
|
|||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
|
|
||||||
m := NewModel(config.Wrap("/tmp/test", cfg), protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
wrapper, path := createTmpWrapper(cfg)
|
||||||
|
defer os.Remove(path)
|
||||||
|
m := NewModel(wrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(cfg.Folders[0])
|
m.AddFolder(cfg.Folders[0])
|
||||||
m.AddFolder(cfg.Folders[1])
|
m.AddFolder(cfg.Folders[1])
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -1406,7 +1451,7 @@ func TestIgnores(t *testing.T) {
|
|||||||
ioutil.WriteFile("testdata/.stignore", []byte(".*\nquux\n"), 0644)
|
ioutil.WriteFile("testdata/.stignore", []byte(".*\nquux\n"), 0644)
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
defer m.Stop()
|
defer m.Stop()
|
||||||
|
|
||||||
@ -1480,7 +1525,7 @@ func TestROScanRecovery(t *testing.T) {
|
|||||||
RescanIntervalS: 1,
|
RescanIntervalS: 1,
|
||||||
MarkerName: config.DefaultMarkerName,
|
MarkerName: config.DefaultMarkerName,
|
||||||
}
|
}
|
||||||
cfg := config.Wrap("/tmp/test", config.Configuration{
|
cfg, path := createTmpWrapper(config.Configuration{
|
||||||
Folders: []config.FolderConfiguration{fcfg},
|
Folders: []config.FolderConfiguration{fcfg},
|
||||||
Devices: []config.DeviceConfiguration{
|
Devices: []config.DeviceConfiguration{
|
||||||
{
|
{
|
||||||
@ -1488,6 +1533,7 @@ func TestROScanRecovery(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
os.RemoveAll(fcfg.Path)
|
os.RemoveAll(fcfg.Path)
|
||||||
|
|
||||||
@ -1568,7 +1614,7 @@ func TestRWScanRecovery(t *testing.T) {
|
|||||||
RescanIntervalS: 1,
|
RescanIntervalS: 1,
|
||||||
MarkerName: config.DefaultMarkerName,
|
MarkerName: config.DefaultMarkerName,
|
||||||
}
|
}
|
||||||
cfg := config.Wrap("/tmp/test", config.Configuration{
|
cfg, path := createTmpWrapper(config.Configuration{
|
||||||
Folders: []config.FolderConfiguration{fcfg},
|
Folders: []config.FolderConfiguration{fcfg},
|
||||||
Devices: []config.DeviceConfiguration{
|
Devices: []config.DeviceConfiguration{
|
||||||
{
|
{
|
||||||
@ -1576,6 +1622,7 @@ func TestRWScanRecovery(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
os.RemoveAll(fcfg.Path)
|
os.RemoveAll(fcfg.Path)
|
||||||
|
|
||||||
@ -1644,7 +1691,7 @@ func TestRWScanRecovery(t *testing.T) {
|
|||||||
|
|
||||||
func TestGlobalDirectoryTree(t *testing.T) {
|
func TestGlobalDirectoryTree(t *testing.T) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
defer m.Stop()
|
defer m.Stop()
|
||||||
@ -1896,7 +1943,7 @@ func TestGlobalDirectoryTree(t *testing.T) {
|
|||||||
|
|
||||||
func TestGlobalDirectorySelfFixing(t *testing.T) {
|
func TestGlobalDirectorySelfFixing(t *testing.T) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
|
|
||||||
@ -2071,7 +2118,7 @@ func BenchmarkTree_100_10(b *testing.B) {
|
|||||||
|
|
||||||
func benchmarkTree(b *testing.B, n1, n2 int) {
|
func benchmarkTree(b *testing.B, n1, n2 int) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
|
|
||||||
@ -2236,7 +2283,7 @@ func TestIssue3028(t *testing.T) {
|
|||||||
// Create a model and default folder
|
// Create a model and default folder
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
defCfg := defaultFolderConfig.Copy()
|
defCfg := defaultFolderConfig.Copy()
|
||||||
defCfg.RescanIntervalS = 86400
|
defCfg.RescanIntervalS = 86400
|
||||||
m.AddFolder(defCfg)
|
m.AddFolder(defCfg)
|
||||||
@ -2278,9 +2325,10 @@ func TestIssue3028(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue4357(t *testing.T) {
|
func TestIssue4357(t *testing.T) {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
cfg := defaultConfig.RawCopy()
|
cfg := defaultCfgWrapper.RawCopy()
|
||||||
// Create a separate wrapper not to pollute other tests.
|
// Create a separate wrapper not to pollute other tests.
|
||||||
wrapper := config.Wrap("/tmp/test", config.Configuration{})
|
wrapper, path := createTmpWrapper(config.Configuration{})
|
||||||
|
defer os.Remove(path)
|
||||||
m := NewModel(wrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(wrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
defer m.Stop()
|
defer m.Stop()
|
||||||
@ -2357,21 +2405,21 @@ func TestScanNoDatabaseWrite(t *testing.T) {
|
|||||||
// something actually changed.
|
// something actually changed.
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
|
|
||||||
// Start with no ignores, and restore the previous state when the test completes
|
// Reach in and update the ignore matcher to one that always does
|
||||||
|
// reloads when asked to, instead of checking file mtimes. This is
|
||||||
|
// because we will be changing the files on disk often enough that the
|
||||||
|
// mtimes will be unreliable to determine change status.
|
||||||
|
m.fmut.Lock()
|
||||||
|
m.folderIgnores["default"] = ignore.New(defaultFs, ignore.WithCache(true), ignore.WithChangeDetector(newAlwaysChanged()))
|
||||||
|
m.fmut.Unlock()
|
||||||
|
|
||||||
curIgn, _, err := m.GetIgnores("default")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer m.SetIgnores("default", curIgn)
|
|
||||||
m.SetIgnores("default", nil)
|
m.SetIgnores("default", nil)
|
||||||
fakeTime := time.Now().Add(5 * time.Second)
|
defer os.Remove("testdata/.stignore")
|
||||||
os.Chtimes("testdata/.stignore", fakeTime, fakeTime)
|
|
||||||
|
|
||||||
// Scan the folder twice. The second scan should be a no-op database wise
|
// Scan the folder twice. The second scan should be a no-op database wise
|
||||||
|
|
||||||
@ -2388,8 +2436,6 @@ func TestScanNoDatabaseWrite(t *testing.T) {
|
|||||||
// Ignore a file we know exists. It'll be updated in the database.
|
// Ignore a file we know exists. It'll be updated in the database.
|
||||||
|
|
||||||
m.SetIgnores("default", []string{"foo"})
|
m.SetIgnores("default", []string{"foo"})
|
||||||
fakeTime = time.Now().Add(10 * time.Second)
|
|
||||||
os.Chtimes("testdata/.stignore", fakeTime, fakeTime)
|
|
||||||
|
|
||||||
m.ScanFolder("default")
|
m.ScanFolder("default")
|
||||||
c2 := db.Committed()
|
c2 := db.Committed()
|
||||||
@ -2441,7 +2487,7 @@ func TestIssue2782(t *testing.T) {
|
|||||||
defer os.RemoveAll(testDir)
|
defer os.RemoveAll(testDir)
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, "~/"+testName+"/synclink/"))
|
m.AddFolder(config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, "~/"+testName+"/synclink/"))
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -2472,7 +2518,7 @@ func TestIndexesForUnknownDevicesDropped(t *testing.T) {
|
|||||||
t.Error("expected two devices")
|
t.Error("expected two devices")
|
||||||
}
|
}
|
||||||
|
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
|
|
||||||
@ -2504,7 +2550,8 @@ func TestSharedWithClearedOnDisconnect(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wcfg := config.Wrap("/tmp/test", cfg)
|
wcfg, path := createTmpWrapper(cfg)
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
m := NewModel(wcfg, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(wcfg, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(fcfg)
|
m.AddFolder(fcfg)
|
||||||
@ -2620,7 +2667,7 @@ func TestIssue3496(t *testing.T) {
|
|||||||
// checks on the completion calculation stuff.
|
// checks on the completion calculation stuff.
|
||||||
|
|
||||||
dbi := db.OpenMemory()
|
dbi := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -2693,7 +2740,7 @@ func TestIssue3496(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue3804(t *testing.T) {
|
func TestIssue3804(t *testing.T) {
|
||||||
dbi := db.OpenMemory()
|
dbi := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -2708,7 +2755,7 @@ func TestIssue3804(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue3829(t *testing.T) {
|
func TestIssue3829(t *testing.T) {
|
||||||
dbi := db.OpenMemory()
|
dbi := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -2743,7 +2790,8 @@ func TestNoRequestsFromPausedDevices(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wcfg := config.Wrap("/tmp/test", cfg)
|
wcfg, path := createTmpWrapper(cfg)
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
m := NewModel(wcfg, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(wcfg, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(fcfg)
|
m.AddFolder(fcfg)
|
||||||
@ -2843,7 +2891,7 @@ func TestIssue2571(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbi := db.OpenMemory()
|
dbi := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -2895,7 +2943,7 @@ func TestIssue4573(t *testing.T) {
|
|||||||
fd.Close()
|
fd.Close()
|
||||||
|
|
||||||
dbi := db.OpenMemory()
|
dbi := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -2964,7 +3012,7 @@ func TestInternalScan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbi := db.OpenMemory()
|
dbi := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -3008,7 +3056,7 @@ func TestCustomMarkerName(t *testing.T) {
|
|||||||
RescanIntervalS: 1,
|
RescanIntervalS: 1,
|
||||||
MarkerName: "myfile",
|
MarkerName: "myfile",
|
||||||
}
|
}
|
||||||
cfg := config.Wrap("/tmp/test", config.Configuration{
|
cfg, path := createTmpWrapper(config.Configuration{
|
||||||
Folders: []config.FolderConfiguration{fcfg},
|
Folders: []config.FolderConfiguration{fcfg},
|
||||||
Devices: []config.DeviceConfiguration{
|
Devices: []config.DeviceConfiguration{
|
||||||
{
|
{
|
||||||
@ -3016,6 +3064,7 @@ func TestCustomMarkerName(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
os.RemoveAll(fcfg.Path)
|
os.RemoveAll(fcfg.Path)
|
||||||
defer os.RemoveAll(fcfg.Path)
|
defer os.RemoveAll(fcfg.Path)
|
||||||
@ -3078,7 +3127,7 @@ func TestRemoveDirWithContent(t *testing.T) {
|
|||||||
fd.Close()
|
fd.Close()
|
||||||
|
|
||||||
dbi := db.OpenMemory()
|
dbi := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -3143,7 +3192,7 @@ func TestIssue4475(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbi := db.OpenMemory()
|
dbi := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
m.StartFolder("default")
|
m.StartFolder("default")
|
||||||
m.ServeBackground()
|
m.ServeBackground()
|
||||||
@ -3225,7 +3274,8 @@ func TestVersionRestore(t *testing.T) {
|
|||||||
rawConfig := config.Configuration{
|
rawConfig := config.Configuration{
|
||||||
Folders: []config.FolderConfiguration{fcfg},
|
Folders: []config.FolderConfiguration{fcfg},
|
||||||
}
|
}
|
||||||
cfg := config.Wrap("/tmp/test", rawConfig)
|
cfg, path := createTmpWrapper(rawConfig)
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
m := NewModel(cfg, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
m := NewModel(cfg, protocol.LocalDeviceID, "syncthing", "dev", dbi, nil)
|
||||||
m.AddFolder(fcfg)
|
m.AddFolder(fcfg)
|
||||||
@ -3417,8 +3467,9 @@ func TestVersionRestore(t *testing.T) {
|
|||||||
|
|
||||||
func TestPausedFolders(t *testing.T) {
|
func TestPausedFolders(t *testing.T) {
|
||||||
// Create a separate wrapper not to pollute other tests.
|
// Create a separate wrapper not to pollute other tests.
|
||||||
cfg := defaultConfig.RawCopy()
|
cfg := defaultCfgWrapper.RawCopy()
|
||||||
wrapper := config.Wrap("/tmp/test", cfg)
|
wrapper, path := createTmpWrapper(cfg)
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(wrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(wrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
|
@ -8,6 +8,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
@ -53,10 +54,11 @@ func expectTimeout(w *events.Subscription, t *testing.T) {
|
|||||||
func TestProgressEmitter(t *testing.T) {
|
func TestProgressEmitter(t *testing.T) {
|
||||||
w := events.Default.Subscribe(events.DownloadProgress)
|
w := events.Default.Subscribe(events.DownloadProgress)
|
||||||
|
|
||||||
c := config.Wrap("/tmp/test", config.Configuration{})
|
c, path := createTmpWrapper(config.Configuration{})
|
||||||
c.SetOptions(config.OptionsConfiguration{
|
c.SetOptions(config.OptionsConfiguration{
|
||||||
ProgressUpdateIntervalS: 0,
|
ProgressUpdateIntervalS: 0,
|
||||||
})
|
})
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
p := NewProgressEmitter(c)
|
p := NewProgressEmitter(c)
|
||||||
go p.Serve()
|
go p.Serve()
|
||||||
@ -101,11 +103,12 @@ func TestProgressEmitter(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSendDownloadProgressMessages(t *testing.T) {
|
func TestSendDownloadProgressMessages(t *testing.T) {
|
||||||
c := config.Wrap("/tmp/test", config.Configuration{})
|
c, path := createTmpWrapper(config.Configuration{})
|
||||||
c.SetOptions(config.OptionsConfiguration{
|
c.SetOptions(config.OptionsConfiguration{
|
||||||
ProgressUpdateIntervalS: 0,
|
ProgressUpdateIntervalS: 0,
|
||||||
TempIndexMinBlocks: 10,
|
TempIndexMinBlocks: 10,
|
||||||
})
|
})
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
fc := &fakeConnection{}
|
fc := &fakeConnection{}
|
||||||
|
|
||||||
|
@ -209,11 +209,10 @@ func TestRequestVersioningSymlinkAttack(t *testing.T) {
|
|||||||
// Sets up a folder with trashcan versioning and tries to use a
|
// Sets up a folder with trashcan versioning and tries to use a
|
||||||
// deleted symlink to escape
|
// deleted symlink to escape
|
||||||
|
|
||||||
tmpDir, err := ioutil.TempDir(".", "_request-")
|
tmpDir := createTmpDir()
|
||||||
if err != nil {
|
defer os.RemoveAll(tmpDir)
|
||||||
panic("Failed to create temporary testing dir")
|
|
||||||
}
|
cfg := defaultCfgWrapper.RawCopy()
|
||||||
cfg := defaultConfig.RawCopy()
|
|
||||||
cfg.Folders[0] = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, tmpDir)
|
cfg.Folders[0] = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, tmpDir)
|
||||||
cfg.Folders[0].Devices = []config.FolderDeviceConfiguration{
|
cfg.Folders[0].Devices = []config.FolderDeviceConfiguration{
|
||||||
{DeviceID: device1},
|
{DeviceID: device1},
|
||||||
@ -222,7 +221,8 @@ func TestRequestVersioningSymlinkAttack(t *testing.T) {
|
|||||||
cfg.Folders[0].Versioning = config.VersioningConfiguration{
|
cfg.Folders[0].Versioning = config.VersioningConfiguration{
|
||||||
Type: "trashcan",
|
Type: "trashcan",
|
||||||
}
|
}
|
||||||
w := config.Wrap("/tmp/cfg", cfg)
|
w, path := createTmpWrapper(cfg)
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(w, device1, "syncthing", "dev", db, nil)
|
m := NewModel(w, device1, "syncthing", "dev", db, nil)
|
||||||
@ -278,7 +278,7 @@ func TestRequestVersioningSymlinkAttack(t *testing.T) {
|
|||||||
for updates := 0; updates < 1; updates += <-idx {
|
for updates := 0; updates < 1; updates += <-idx {
|
||||||
}
|
}
|
||||||
|
|
||||||
path := filepath.Join(tmpdir, "test")
|
path = filepath.Join(tmpdir, "test")
|
||||||
if _, err := os.Lstat(path); !os.IsNotExist(err) {
|
if _, err := os.Lstat(path); !os.IsNotExist(err) {
|
||||||
t.Fatal("File escaped to", path)
|
t.Fatal("File escaped to", path)
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ func pullInvalidIgnored(t *testing.T, ft config.FolderType) {
|
|||||||
tmpDir := createTmpDir()
|
tmpDir := createTmpDir()
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
cfg := defaultConfig.RawCopy()
|
cfg := defaultCfgWrapper.RawCopy()
|
||||||
cfg.Devices = append(cfg.Devices, config.NewDeviceConfiguration(device2, "device2"))
|
cfg.Devices = append(cfg.Devices, config.NewDeviceConfiguration(device2, "device2"))
|
||||||
cfg.Folders[0] = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, tmpDir)
|
cfg.Folders[0] = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, tmpDir)
|
||||||
cfg.Folders[0].Devices = []config.FolderDeviceConfiguration{
|
cfg.Folders[0].Devices = []config.FolderDeviceConfiguration{
|
||||||
@ -427,7 +427,7 @@ func pullInvalidIgnored(t *testing.T, ft config.FolderType) {
|
|||||||
|
|
||||||
func setupModelWithConnection() (*Model, *fakeConnection, string) {
|
func setupModelWithConnection() (*Model, *fakeConnection, string) {
|
||||||
tmpDir := createTmpDir()
|
tmpDir := createTmpDir()
|
||||||
cfg := defaultConfig.RawCopy()
|
cfg := defaultCfgWrapper.RawCopy()
|
||||||
cfg.Devices = append(cfg.Devices, config.NewDeviceConfiguration(device2, "device2"))
|
cfg.Devices = append(cfg.Devices, config.NewDeviceConfiguration(device2, "device2"))
|
||||||
cfg.Folders[0] = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, tmpDir)
|
cfg.Folders[0] = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, tmpDir)
|
||||||
cfg.Folders[0].Devices = []config.FolderDeviceConfiguration{
|
cfg.Folders[0].Devices = []config.FolderDeviceConfiguration{
|
||||||
@ -439,7 +439,8 @@ func setupModelWithConnection() (*Model, *fakeConnection, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupModelWithConnectionManual(cfg config.Configuration) (*Model, *fakeConnection) {
|
func setupModelWithConnectionManual(cfg config.Configuration) (*Model, *fakeConnection) {
|
||||||
w := config.Wrap("/tmp/cfg", cfg)
|
w, path := createTmpWrapper(cfg)
|
||||||
|
defer os.Remove(path)
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(w, device1, "syncthing", "dev", db, nil)
|
m := NewModel(w, device1, "syncthing", "dev", db, nil)
|
||||||
@ -456,7 +457,7 @@ func setupModelWithConnectionManual(cfg config.Configuration) (*Model, *fakeConn
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createTmpDir() string {
|
func createTmpDir() string {
|
||||||
tmpDir, err := ioutil.TempDir(".", "_request-")
|
tmpDir, err := ioutil.TempDir("testdata", "_request-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Failed to create temporary testing dir")
|
panic("Failed to create temporary testing dir")
|
||||||
}
|
}
|
||||||
|
@ -26,25 +26,6 @@ import (
|
|||||||
"github.com/syncthing/syncthing/lib/sync"
|
"github.com/syncthing/syncthing/lib/sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
|
||||||
// We do this to make sure that the temp file required for the tests
|
|
||||||
// does not get removed during the tests. Also set the prefix so it's
|
|
||||||
// found correctly regardless of platform.
|
|
||||||
if fs.TempPrefix != fs.WindowsTempPrefix {
|
|
||||||
originalPrefix := fs.TempPrefix
|
|
||||||
fs.TempPrefix = fs.WindowsTempPrefix
|
|
||||||
defer func() {
|
|
||||||
fs.TempPrefix = originalPrefix
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
future := time.Now().Add(time.Hour)
|
|
||||||
err := os.Chtimes(filepath.Join("testdata", fs.TempName("file")), future, future)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
os.Exit(m.Run())
|
|
||||||
}
|
|
||||||
|
|
||||||
var blocks = []protocol.BlockInfo{
|
var blocks = []protocol.BlockInfo{
|
||||||
{Hash: []uint8{0xfa, 0x43, 0x23, 0x9b, 0xce, 0xe7, 0xb9, 0x7c, 0xa6, 0x2f, 0x0, 0x7c, 0xc6, 0x84, 0x87, 0x56, 0xa, 0x39, 0xe1, 0x9f, 0x74, 0xf3, 0xdd, 0xe7, 0x48, 0x6d, 0xb3, 0xf9, 0x8d, 0xf8, 0xe4, 0x71}}, // Zero'ed out block
|
{Hash: []uint8{0xfa, 0x43, 0x23, 0x9b, 0xce, 0xe7, 0xb9, 0x7c, 0xa6, 0x2f, 0x0, 0x7c, 0xc6, 0x84, 0x87, 0x56, 0xa, 0x39, 0xe1, 0x9f, 0x74, 0xf3, 0xdd, 0xe7, 0x48, 0x6d, 0xb3, 0xf9, 0x8d, 0xf8, 0xe4, 0x71}}, // Zero'ed out block
|
||||||
{Offset: 0, Size: 0x20000, Hash: []uint8{0x7e, 0xad, 0xbc, 0x36, 0xae, 0xbb, 0xcf, 0x74, 0x43, 0xe2, 0x7a, 0x5a, 0x4b, 0xb8, 0x5b, 0xce, 0xe6, 0x9e, 0x1e, 0x10, 0xf9, 0x8a, 0xbc, 0x77, 0x95, 0x2, 0x29, 0x60, 0x9e, 0x96, 0xae, 0x6c}},
|
{Offset: 0, Size: 0x20000, Hash: []uint8{0x7e, 0xad, 0xbc, 0x36, 0xae, 0xbb, 0xcf, 0x74, 0x43, 0xe2, 0x7a, 0x5a, 0x4b, 0xb8, 0x5b, 0xce, 0xe6, 0x9e, 0x1e, 0x10, 0xf9, 0x8a, 0xbc, 0x77, 0x95, 0x2, 0x29, 0x60, 0x9e, 0x96, 0xae, 0x6c}},
|
||||||
@ -94,7 +75,7 @@ func setUpFile(filename string, blockNumbers []int) protocol.FileInfo {
|
|||||||
|
|
||||||
func setUpModel(file protocol.FileInfo) *Model {
|
func setUpModel(file protocol.FileInfo) *Model {
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
model := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
model := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
model.AddFolder(defaultFolderConfig)
|
model.AddFolder(defaultFolderConfig)
|
||||||
// Update index
|
// Update index
|
||||||
model.updateLocalsFromScanning("default", []protocol.FileInfo{file})
|
model.updateLocalsFromScanning("default", []protocol.FileInfo{file})
|
||||||
@ -224,6 +205,7 @@ func TestCopierFinder(t *testing.T) {
|
|||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
defer os.Remove(tempFile)
|
||||||
|
|
||||||
existingBlocks := []int{0, 2, 3, 4, 0, 0, 7, 0}
|
existingBlocks := []int{0, 2, 3, 4, 0, 0, 7, 0}
|
||||||
existingFile := setUpFile(fs.TempName("file"), existingBlocks)
|
existingFile := setUpFile(fs.TempName("file"), existingBlocks)
|
||||||
@ -285,8 +267,6 @@ func TestCopierFinder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
finish.fd.Close()
|
finish.fd.Close()
|
||||||
|
|
||||||
os.Remove(tempFile)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWeakHash(t *testing.T) {
|
func TestWeakHash(t *testing.T) {
|
||||||
@ -506,7 +486,7 @@ func TestDeregisterOnFailInCopy(t *testing.T) {
|
|||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
|
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
|
|
||||||
f := setUpSendReceiveFolder(m)
|
f := setUpSendReceiveFolder(m)
|
||||||
@ -580,7 +560,7 @@ func TestDeregisterOnFailInPull(t *testing.T) {
|
|||||||
defer os.Remove("testdata/" + fs.TempName("filex"))
|
defer os.Remove("testdata/" + fs.TempName("filex"))
|
||||||
|
|
||||||
db := db.OpenMemory()
|
db := db.OpenMemory()
|
||||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||||
m.AddFolder(defaultFolderConfig)
|
m.AddFolder(defaultFolderConfig)
|
||||||
|
|
||||||
f := setUpSendReceiveFolder(m)
|
f := setUpSendReceiveFolder(m)
|
||||||
|
2
lib/model/testdata/.stignore
vendored
2
lib/model/testdata/.stignore
vendored
@ -1,2 +0,0 @@
|
|||||||
.*
|
|
||||||
quux
|
|
Loading…
Reference in New Issue
Block a user